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: Re: problem with split command
From
Prakash Singh <[email protected]>
To
[email protected]
Subject
Re: st: Re: problem with split command
Date
Wed, 29 Feb 2012 10:37:50 +0530
Thanks a lot Joseph
On Wed, Feb 29, 2012 at 9:19 AM, Joseph Coveney <[email protected]> wrote:
>
> Forgot to mention: for this year's survey and afterward, try the
> alternative below. You can use Stata's regular expressions, too.
>
> Joseph Coveney
>
>
> . input str30 state_name
>
> state_name
> 1. "Andhra2012"
> 2. "Arunachal2012"
> 3. "Assam2012"
> 4. "Bihar2012"
> 5. "UttarPradesh2012"
> 6. end
>
> .
> . generate byte first_numeral = indexnot(state_name,
> "`c(alpha)'`c(ALPHA)'")
>
> . generate long year = real(substr(state_name, first_numeral, .))
>
> . replace state_name = substr(state_name, 1, first_numeral - 1)
> (5 real changes made)
>
> .
> . list, noobs separator(0) abbreviate(20)
>
> +-------------------------------------+
> | state_name first_numeral year |
> |-------------------------------------|
> | Andhra 7 2012 |
> | Arunachal 10 2012 |
> | Assam 6 2012 |
> | Bihar 6 2012 |
> | UttarPradesh 13 2012 |
> +-------------------------------------+
>
> .
> . exit
>
> end of do-file
>
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/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/statalist/faq
* http://www.ats.ucla.edu/stat/stata/