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

st: RE: corresponding Stata command to SAS "retain" command


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: corresponding Stata command to SAS "retain" command
Date   Fri, 22 Nov 2002 18:45:08 -0000

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/



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