Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: generating a variable as a subset of a numeric one


From   "R.E. De Hoyos" <[email protected]>
To   <[email protected]>
Subject   st: generating a variable as a subset of a numeric one
Date   Tue, 24 Feb 2004 17:13:56 -0000

I have a 4 or 5-digits numeric variable (format: int) containing information
on state (first 1 or 2 digits) and municipality (remaining 3 digits).

Region
 1001
 1002



32001
32002




I want to create a new dummy variable (North) that takes the value of one if
the state belongs to certain category. I can:

gen North=0
replace North = 1 if Region >1000 | Region < 2000

But I will have to this for each state belonging to category North. I
thought of the -inlist- command, however first I have to create a data set
like the following:

Region      State       Municipality
 1001          1                1
 1002          1                2



32001         32              1
32002         32              2



I don't know how to do this; perhaps is not necessary.

Any suggestions?

Thanks

rafa
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index