Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: loop code question

From   "Kaur, Dupinderjeet" <>
To   "" <>
Subject   st: loop code question
Date   Sat, 11 Aug 2012 21:12:56 +0000

Dear All,

I have two questions on using a loop to run regressions. 

1)	I want to use pair of variables together when doing foreach, right now to do this I am doing a double loop and delegating combinations that I don't want.
Here is the code, I need A a, B b, C c combination. How can I do this in a single loop?
                foreach x in A B C{
                                foreach y in a b c{ 
                                eststo: quietly reg dependent independent  `x' `y' 
2)	I have panel data with ID and year. I want to run event regressions. For example if my data is from 1990 to 2010, and I have identified events in 1994, 
1998, 2005 then I want to run three regressions capturing 2 years data on both sides of the event year. Can I do a categorical variable that differentiates 
these events and then do a loop for regression, I am not sure how to do this exactly.

I am a second year PhD student and new to Stata, so any guidance on these questions would be greatly appreciated.

Thank you.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index