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]

Re: st: sort of standardization


From   Ginevra Biino <biino@igm.cnr.it>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: sort of standardization
Date   Wed, 12 May 2010 16:52:56 +0200

many thanks
Ginevra


----- Original Message ----- From: "Richard Goldstein" <richgold@ix.netcom.com>
To: <statalist@hsphsun2.harvard.edu>
Cc: "Ginevra Biino" <biino@igm.cnr.it>
Sent: Wednesday, May 12, 2010 4:39 PM
Subject: Re: st: sort of standardization


if I understand correctly what you want, I would do the following within
a -foreach- loop:

summarize variable
calculate the range from r(min) and r(max)
divide the old variable by this calculated range inside a -gen-

e.g.,

foreach var of varlist .... {
qui su `var'
local range=r(max)-r(min)+1
gen `var'3=`var'/`range'
}

Rich

On 5/12/10 10:29 AM, Ginevra Biino wrote:
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/
*
*   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