Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Re: problem with split command


From   Prakash Singh <prakashbhu@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <jcoveney@bigplanet.com> 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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index