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

st: create dummy variables for every 5 values


From   Lynda Zhang <lzhang@hmdc.harvard.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: create dummy variables for every 5 values
Date   Thu, 10 Nov 2005 16:52:28 -0500

I have a variable Year:
...
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
...

How do I create one dummy variable for each 5-year interval with one command.

Typically I can get it manually by generating one dummy at a time
gen year1=1 if year>=1991 & year<=1995
...

or using Recode:
gen yr=year
recode yr (1991/1995=1)(1996/2000=2)
tab yr, g(y)

Thanks a lot!
Lynda

begin:vcard
fn:Lynda Zhang
n:Zhang;Lynda
email;internet:lzhang@hmdc.harvard.edu
version:2.1
end:vcard




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