Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Replace with returned results in svy loop


From   Kate Schneider <[email protected]>
To   [email protected]
Subject   st: Replace with returned results in svy loop
Date   Sun, 29 May 2011 13:11:36 -0700

Hello,
Sorr to bug everyone on a holiday weekend, but we're a graduate
student research group at the University of Washington working with a
large household survey dataset and have come up against some trouble.

We're trying to replace missing values of a variable with the results
of some other operation we've just performed (basically, a mean).
Right now, we're having trouble with the replace component of the
below operation. Does anyone know how torecall the previous command's
results from the svy calculation and use that data to replace missing
in a loop?  Is this possible with survey data?

foreach X of varlist $fooditemall {
quietly count if `X'==1 & priceperkilo !=.
 if `r(N)'>0 {
 display "Variable is: " "`X'"
 svy, subpop(`X'): mean priceperkilo
 }
quietly count if `X'==1 & priceperkilo ==.
 if `r(N)'>0 {
 replace priceperkilo == e(????) if `X'==1 & priceperkilo ==.
 }
}

Thanks for your insight!  If you need more information please let me know.
Kate

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index