|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Looping in each of 5 imputed datasets
I am using Stata 10 in Windows. I have multiply imputed data that I
imputed using -ice-. I want to eventually be able to run the
-psmatch2- and -pstest- commands in each of my 5 imputed data sets. I
would like to tell Stata to run these commands, first in dataset
_mj=1, then in dataset _mj=2, and so on through dataset _mj=5. A
colleague was kind enough to share some code with me, but I can't get
it run. Specifically, after the -psmatch2- line, I get an "invalid
syntax" message. Here is the code I have been trying to use:
gen weight1=.;
gen pscore1=.;
forvalues x=1/5{;
set seed 339487731;
gen r = uniform();
sort _mj r;
drop r;
psmatch2 treatment covars covars outcome if _mj==`x',
outcome(outcome) noreplacement desc common trim(10);
pstest covars covars outcome, sum ;
replace weight1=_weight if _mj==`x';
replace pscore1=_pscore if _mj==`x';
I imagine somewhere in there I need to specify that the 'x' represents
each of the _mj datasets, but I don't know how to do this. Any help
would be greatly appreciated.
Many thanks.
-Anna
*
* 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/