Hello,
I am using a panel dataset. It both id and ic variable (ic: income category: HI, LI, LMI, UMI)
I want to write a loop that performs a dickeyfuller test for each id in ic. The following table summerizes the data:
ic id
HI 1 to 42
LI 43 to 61
LMI 62 to 86
UMI 87 to 118
The loop is as follows:
use si1981, clear
sort ic cc year
egen id1=group(ic cc)
encode ic, gen(ic1)
foreach i of numlist 1/4 {
foreach j of numlist 1/42 43/61 62/86 87/118 {
tab ic id if id1==`i'
dfuller gcf, drift lags(4), if ic1==`i' & id1==`j'
}
}
*
The above code works for first ic (i.e., HI). I want the double-loop to run the test for all ids in each ic.
I am a beginner in looping. I was wondering if local or global can help me out.
Thank you in advance.
Related Posts with Looping within a loop
Three-tier Multi-Level Model: violation of the assumptions of normality and heteroscedasticity Dear colleagues, I am working with educational data. To do so, I am using the classic three-level h…
How to set up a time-dependent Cox model in Stata?Hello everyone, I need to conduct an analysis, but the exposure can occur after the origin time. I h…
Page Up and Page Down don't work on LinuxThe documentation says: Page Upsteps backward through the command history. Page Downsteps forwar…
Lasso for selection of variables and running logit regression using selected variables in lassoHi all, Can someone help me please, I am assessing the impact of income(X1) on economic growth (Y) b…
Geocoding in StataI have address variable (~700k observations) and I would like to get latitude and longitude of the a…
Subscribe to:
Post Comments (Atom)
0 Response to Looping within a loop
Post a Comment