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: sd() does not work with forvalues


From   Wilhelm Kluemper <wilhelmkluemper@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: sd() does not work with forvalues
Date   Fri, 15 Jul 2011 19:20:42 +0200

Hello STATA community,

I am trying out a code where I want to create the standard deviation
of a var as a new var with a loop:

dfbeta

forvalues i = 3/85 {
egen df`i'med = median(_dfbeta_`i')
egen sddf`i'= sd(_dfbeta_`i')
gen diffmedi`i'=_dfbeta_`i'-df`i'med
gen absdiffmedi`i' = abs(diffmedi`i')
gen nosddff`i'= diffmedi`i'/sd(_dfbeta_`i')
drop if nosddff`i'>=2
}

I keep getting this message:

unknown function sd()

It works perfectly without the forvalues loop but not within. Does
anybody have a clue why that is and what I could do about it?

Thanks already

Wilhelm


-- 
Wilhelm Klümper
University of Göttingen

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