Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: sort of standardization


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: sort of standardization
Date   Wed, 12 May 2010 16:37:16 +0200

<> 

No html, right?

*************
clear*

set obs 100

gen x1=rnormal()
gen x2=rnormal()
gen str5 x3="Hello"

qui ds, has(type numeric)


foreach var of varlist `r(varlist)'{
	egen std_`var'=std(`var')
	su `var', mean
	
	gen rangecorrected_`var'=`var'/(`r(max)'-`r(min)')
}
*************



HTH
Martin

Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ginevra Biino
Gesendet: Mittwoch, 12. Mai 2010 16:30
An: Statalist
Betreff: st: sort of standardization

Dear Statalist,
I have to standardize many variables (in order to run PCA).
Besides generating the n corresponding std(varname) vars, which I have
already done, I also want to generate n new  variables obtained dividing
each variable by its range. Can anybody help me?
Ginevra
 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index