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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Looping or macro needed???


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Looping or macro needed???
Date   Thu, 2 Jun 2011 21:02:46 +0100

A loop could be

foreach s in aaa bbb ccc ddd eee fff ggg hhh {
       use  "P:\ProjectName \Mat070809_`s'.dta, clear
       ...
}

Nick

On Thu, Jun 2, 2011 at 8:38 PM, Jennifer A Hoff
<jennifer.lindquist@duke.edu> wrote:
> I am running a regression and calculating a couple of difference in
> difference using data set Mat070809_aaa.
>
> Ie.    use "P:\ProjectName \Mat070809_aaa.dta"
>
> I have the do file up and working for this one dataset.
>
>
> I now need to repeat the same regression for 7 more data sets
> Mat070809_bbb, Mat070809_ccc, Mat070809_ddd, Mat070809_eee, Mat070809_fff,
>
> Mat070809_ggg, Mat070809_hhh
>
> I am a very new Stata user but it seems to beg for some type of looping or
>
> macro.
>
> Especially when I anticipate having to re-run each of the 8 regressions
> with 3 strata!  - Running 24 separate do files seems inefficient.
>

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