Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Remove the middle part of a string variable


From   Phil Clayton <[email protected]>
To   [email protected]
Subject   Re: st: Remove the middle part of a string variable
Date   Mon, 6 Jan 2014 11:27:24 +1100

Here's one solution using regular expressions:
replace myvar=regexs(1) + regexs(2) if regexm(myvar, "(.*)\..*([A-Z])")

Phil

On 6 Jan 2014, at 11:13 am, manon <[email protected]> wrote:

> Stata/IC 12.0 for Mac (64-bit Intel)
> Revision 24 Aug 2011
> 
> Dear all,
> 
> I would like to remove the middle part of a string variable.
> 
> I have a variable of the form:
> 123.01A
> 124
> 135.02
> 12.00B
> 13.23K
> 
> I want to remove the numbers between the "." and the letters.
> In this example, I would want to get:
> 123A
> 124
> 135.02
> 12B
> 13K
> 
> Could you please help me?
> Thanks in advance,
> 
> Manon
> 
> 
> 
> --
> View this message in context: http://statalist.1588530.n2.nabble.com/Remove-the-middle-part-of-a-string-variable-tp7580472.html
> Sent from the Statalist mailing list archive at Nabble.com.
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index