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, is already up and running.

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

st: Re: problem with split command

From   "Joseph Coveney" <>
To   <>
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

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:

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