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

st: create dummy variable for each five values


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: create dummy variable for each five values
Date   Fri, 11 Nov 2005 07:24:00 -0500

The solutions posted seem excessively cumbersome.

. set obs 30
obs was 0, now 30

. g year=_n+1969

. g quin=int((_n-1)/5)

. tab quin,gen(dquin)


Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html


On Nov 11, 2005, at 2:33 AM, Lynda wrote:


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