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, is already up and running.

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

st: Replace with returned results in svy loop

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

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.

*   For searches and help try:

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