Guanghui Li
> I am in the process of transfering a file from SAS to
> Stata. I encountered a problem.
> In Sas, command "retain" can create a large quantity of
> variables and set
> them all equal to zero at the same time.
> If it is only a couple of variables, I can easily do it in Stata:
>
> gen x=0;
> gen y=0;
>
> however, I have almost a hundred of them.
> Is there a similiar command in Stata that does that?
Sure.
forval i = 1/100 {
gen x`i' = 0
}
More generally, see Stata Journal 2(2), 202-222 (2002)
or
http://www.stata.com/support/meeting/8uk/fortitude.pdf
Nick
[email protected]
*
* 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/