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]
st: Re: problem with split command
From
"Joseph Coveney" <[email protected]>
To
<[email protected]>
Subject
st: Re: problem with split command
Date
Wed, 29 Feb 2012 12:35:11 +0900
Prakash Singh wrote:
I need help on using split command. I am working with stata 10.
I am working with survey data of Indian states, In the survey data the
variable state_name are put jointly with year in which the state is
surveyed, in this case 2005 to 2009. So the state_name variable looks
like...
Andhra2006
Arunachal2005
Assam2006
Bihar2007
UttarPradesh2009
and so on.
Now I would like to create two saperate variable out of it i.e.
state_name and year_survey.
I have used the following command
split state_name, pares(2) gen(statename)
But the problem I am facing is the statename2 variable which is
actually year variable is coming without 2 i.e. 005, 006 etc.
Please suggest me as I have read the split help and stat list postings
on split but could not work it out.
--------------------------------------------------------------------------------
You're almost there: finish the job by concatenating "2" and statename2:
generate int year = real("2" + statename2)
Joseph Coveney
*
* 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/