Right in sprit, but
First example is wrong.
Second example starts 0,0,0,0.
Nick
[email protected]
Newson, Roger B
> I think what you are looking for is a combination of the
> system variable
> _n (order of observation in a dataset) and the -mod()-, -int()-,
> -floor()- and -ceil()- functions. For on-line help for functions in
> Stata, type in Stata
>
> whelp functions
>
> Your first example can be created, as the variable -fact1-, by typing
>
> gene fact1=mod(_n,4)+1
>
> and your second example can be created, as the variable -fact2-, by
> typing
>
> gene fact2=int((_n-1)/4)
*
* 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/