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

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


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: generating a variable as a subset of a numeric one
Date   Tue, 24 Feb 2004 17:21:27 -0000

The state is given by 

gen State = floor(Region/1000) 

The municipality through 

gen Municipality = mod(Region,1000) 

I'm not sure that you do want dummies, 
but they are easily obtained through 
-tabulate-. 

Nick 
[email protected] 

R.E. De Hoyos
 
> 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
> 

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