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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: Looping in each of 5 imputed datasets |

Date |
Sat, 6 Feb 2010 22:57:47 +0100 |

<> My code may disappoint b/c Outlook spell-corrected -vers- to -Vers-. You want to undo this before running it. I suspect this chain of event also led to "r(Var)" being capitalized in the r-returns after -summarize- (hard to find bug when you are time constrained...) HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss Sent: Samstag, 6. Februar 2010 22:52 To: statalist@hsphsun2.harvard.edu Subject: st: RE: Looping in each of 5 imputed datasets <> Actually, the way you condition on the "_mj" looks good to me - and works in my example below. -statsby- could be a convenient alternative for you. You should -set trace on- just before the -psmatch2- call and report the area around the error to the list. ******* Vers 10.1 clear* set obs 1000 forv i=1/10{ gen x`i'=rnormal() replace x`i'=. if runiform()<.2 } ice x1 x2 x3, saving(imputed) m(5) replace u imputed, clear forv x=1/5{ reg x1 x2 if _mj==`x' } ******* HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Anna D. Johnson Sent: Samstag, 6. Februar 2010 17:25 To: statalist@hsphsun2.harvard.edu Subject: 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/ * * 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/ * * 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/

**References**:**st: Looping in each of 5 imputed datasets***From:*"Anna D. Johnson" <adj2106@columbia.edu>

**st: RE: Looping in each of 5 imputed datasets***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: RE: Looping in each of 5 imputed datasets** - Next by Date:
**RE: st: confirm file(s) exist before processing - thread closed** - Previous by thread:
**st: RE: Looping in each of 5 imputed datasets** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |