foreach var of varlist _all {
egen z`var' = std(`var')
}
Instead of using the keyword -_all- to represent every variable in the
data set (this may not be appropriate) you could of course specify the
variables individually:
foreach var of varlist var1 var2 var3 var4 <etc> {
egen z`var' = std(`var')
}
or use wildcards if the variable stub is common:
foreach var of varlist var* {
egen z`var' = std(`var')
}
or use lists of variables that are adjacent in the data set:
foreach var of varlist var1-var36 {
egen z`var' = std(`var')
}
see -help foreach- and -help varlist-
Phil
At 07:48 PM 29/12/2002 -0600, you wrote:
Statlisters,
I know this is a really basic question, but I really can't figure something
out:
I want to standardize the variables in my dataset (there are 36) without
typing "egen zvar1=std(var1)" 36 times.
Is there a quicker way to get Stata to standardize all variables in a dataset
at once?
I searched through some past archives before filling your inboxes with what
feels like a way-too-simple question but didn't find anything. Any advice?
Many thanks, and Happy New Year.
*
* 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/
Philip Ryan
A/Professor and Head,
Department of Public Health
University of Adelaide 5005
South Australia
tel 61 8 8303 3570
fax 61 8 8223 4075
http://www.public-health.adelaide.edu.au/
===========================================
This email message is intended only for the addressee(s)
and contains information which may be confidential and/or
copyright. If you are not the intended recipient please
do not read, save, forward, disclose, or copy the contents
of this email. If this email has been sent to you in error,
please notify the sender by reply email and delete this
email and any copies or links to this email completely and
immediately from your system. No representation is made
that this email is free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.
===========================================
*
* 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/