Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: loop code question
From
"Kaur, Dupinderjeet" <[email protected]>
To
"[email protected]" <[email protected]>
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.
Dupinder
*
* 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/