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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Normalize Variables by s.d. (programmatically)


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Normalize Variables by s.d. (programmatically)
Date   Thu, 22 Dec 2011 15:42:19 +0100

Ryan,

If you already have created your dummies, you migth want to pass them
in an option. This way you do not need to identify the dummies in
<varlist>. Kit's program would then read

prog drop _all
prog stdize
syntax varlist(ts) [if] [in] [, dummies(varlist) *]
tsunab vl: `varlist'
marksample touse
tempvar rs
qui g `rs' = 0 if `touse'
foreach w of local vl {
	qui replace `rs' = `rs' + `w' if `touse'
}
preserve
foreach w of local vl {
	qui summ `w' if `touse' & !mi(`rs')
	tempvar ww
	qui g `ww' = `w' / r(sd) if `touse' & !mi(`rs')
	loc neww: subinstr loc w "." "_"
	rename `ww' _`neww'
	loc vl2 "`vl2' _`neww'"
}
xtreg `vl2' `dummies', `options'
restore
end

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