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

st: Re: standardizing


From   baum <[email protected]>
To   [email protected]
Subject   st: Re: standardizing
Date   Mon, 30 Dec 2002 06:12:01 -0500

--On Monday, December 30, 2002 2:33 -0500 Sheela wrote:

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?
And one solution that has not been offered... constructs like var1-var36 require that the 36 variables be contiguous in your data set (which they nay not be). The wildcard var* is inappropriate if there are some var* that should not be z'd, and _all is not likely to be appropriate in many circumstances. A solution that avoids these (assuming that there really are 36 vars) is

forval i=1/36 {
egen zvar`i'=std(var`i')
}

which unlike the solution with 'foreach' does not require that the variables be listed, nor does it make any assumptions about the ordering of variables in the data set.

Kit
________________________________________________________________________
Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA
[email protected] http://fmwww.bc.edu/ec/baum.php



*
* 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