Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: z scores


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: z scores
Date   Fri, 4 May 2007 17:07:34 +0100

This is true -- you can do this -- but the -detail- option 
would cause -summarize- to do unnecessary work. 
And overwriting existing variables is dubious
practice here. 

In general, I think there are at least three good ways 
to do this. 

1. -center- from SSC, as mentioned. 

2. 
foreach v of var <varlist> { 
	qui su `v' 
	gen z_`v' = (`v' - r(mean)) / r(sd) 
}

3. 

foreach v of var <varlist> { 
	egen z_`v' = std(`v') 
} 

Nick 
[email protected] 

Masahiko Aida
 
> You can simply program
> 
> 
> foreach var of varlist var*{ 
> quietly: su `var' , de
> replace `var' = (`var' - `r(mean)') / `r(sd)'
> }

Donald Braman

> I need to calculate z-scores for a large number of variables. Does
> anyone have a macro/script for z-score calculations of this sort, or
> know of an ADO that can do it?  (I'm relatively new to STATA & miss
> the ease of the z-score function as part of descriptives in SPSS.)

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