Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Abdel Rahmen El Lahga <rahmen.lahga@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Stata programming question |
Date | Wed, 17 Feb 2010 23:53:46 +0100 |
Suppose that your dependent variable are v1, v2,..., v44 and your independent cariable are x1, x2 and x3 you can try the following code ************************ global indep x1 x2 x3 foreach var of varlist v1 v2...v44 { qui logit `var' $indep predict p_`var' } *********** For a more complete solution, you should be more explicit about your condition concerning the use of a subset of data 2010/2/17 Data Analytics Corp. <walt@dataanalyticscorp.com>: > Hi, > > I have a simple programming problem, and since I'm not familiar with Stata > programming I need some help. > > I have to do 44 logit regressions and predictions where the only thing that > changes from regression to regression is the dependent variable. Each > regression uses a subset of the data. At the end of each regression, I > predict the dependent variable for the remaining portion of the data, saving > the prediction as p_dependentVariableName. I'd like to create a loop where > the dependent variable will change in each pass through the loop and that > variable name will be attached to p_ for the prediction. > > How can I do this? Any help is appreciated. > > Thanks, > > Walt > > > > -- > ________________________ > > Walter R. Paczkowski, Ph.D. > Data Analytics Corp. > 44 Hamilton Lane > Plainsboro, NJ 08536 > ________________________ > (V) 609-936-8999 > (F) 609-936-3733 > walt@dataanalyticscorp.com > www.dataanalyticscorp.com > > * > * 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/ > -- AbdelRahmen El Lahga * * 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/