bysort var2: gen var4 = _N
bysort var2: gen var5 = _n
See - help _variables -
N.Orsini
----- Original Message -----
From: Dongshu Ou <[email protected]>
Date: Sunday, December 12, 2004 5:18 am
Subject: st: Re: Questions on Stata
> >
> > >
> > > data set looks like
> > >
> > > var1 var2 var3
> > >
> > > 80 30 1
> > > 75 30 1
> > > 85 30 1
> > > 76 33 1
> > > 78 33 1
> > > 75 33 1
> > > 80 29 2
> > > 82 29 2
> > > 83 29 2
> > > ...................
> > >
> > > Say, var1 is an indicator measured at 3 different times of each
> > > individual. var2 is age, var3 indicates "group"
> > >
> > > I want to generate a variable to indicate every three of the var1
> > > belongs to the same person, and a variable indicating three
> > > different times for the same person , which would be looked like:
> > >
> > > var1 var2 var3 Var4 Var5
> > >
> > > 80 30 1 1 1
> > > 75 30 1 1 2
> > > 85 30 1 1 3
> > > 76 33 1 2 1
> > > 78 33 1 2 2
> > > 75 33 1 2 3
> > > 80 29 2 3 1
> > > 82 29 2 3 2
> > > 83 29 2 3 3
> > > ................... ..........
>
>
> What Stata Command I should use then?? Thank you very much!!
> *
> * 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/