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: separating components of a string variable
From
Richard Goldstein <[email protected]>
To
[email protected]
Subject
Re: st: separating components of a string variable
Date
Mon, 01 Oct 2012 15:49:22 -0400
Yes, Nick is correct - thanks
On 10/1/12 3:41 PM, Nick Cox wrote:
> Rich means -generate-, not -egen-.
>
> Nick
>
> On Mon, Oct 1, 2012 at 8:37 PM, Richard Goldstein
> <[email protected]> wrote:
>> use -egen- with the substr function as in
>>
>> egen newvar=substr(oldvar,2,2)
>>
>> egen newvar2=substr(oldvar2,-3,.)
>>
>> Rich
>>
>> On 10/1/12 3:32 PM, Mahbubeh Parsaeian wrote:
>>> Hi everybody.
>>> I have a question about separating the component of a string variable.
>>> Suppose you have a string variable which is an id variable and consists of 9 numbers.
>> The second and third numbers introduce the province and you want
>>> to separate this part of the string variable and save it as a new
>>> variable.
>>> I also have another question. I have an id number such as 123456 and I want
>>> to separate 3 numbers from the right side (456).
>>> Would you please help me to find good solutions for these questions?
> *
> * 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/