On Wed, 24 Sep 2003, Wade T Roberts wrote:
> Hi, I was hoping someone might be able to shed some light on this issue.
>
> I have a single numeric variable that identifies the city/county/state
> for
> each case, where the first three digits represent the city, the next two
> the county, and the final two represent the state.
>
> Examples:
>
> 223406
> 1453209
> 2785845
> etc...
>
> I'm only interested in identifying cases by state at the moment. How do
> I
> go about singling out this part of the data, or creating a new
> identifying
> state variable?
gen newvar=string(oldvar)
gen state=substr(newvar,n1,n2)
where n1 is the first digit of the variable to appear on state and n2 is
the last digit. For example:
if newvar(i)=1453209
then gen state(i)=substr(newvar,5,7) will generate state(i)=09
hope this helps.
Fernando
_____________________________________________________________________________________
On Wed, 24 Sep 2003, Wade T Roberts wrote:
> Hi, I was hoping someone might be able to shed some light on this issue.
>
> I have a single numeric variable that identifies the city/county/state for
> each case, where the first three digits represent the city, the next two
> the county, and the final two represent the state.
>
> Examples:
>
> 223406
> 1453209
> 2785845
> etc...
>
> I'm only interested in identifying cases by state at the moment. How do I
> go about singling out this part of the data, or creating a new identifying
> state variable?
>
> Thanks for any help.
>
> Wade
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/