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
Reshaping multiple variables at onceHi All, I have data that resembles the following: Code: * Example generated by -dataex-. To insta…
Hausman Test producing different resultsI am using panel data and trying to decide between the fixed and random effects models to use. When…
Collapse by what?Hi everyone, I have the following database which I describe quickly. Basically it is a escalation o…
Multiple imputation when there is a certain group that did not answer a certain questionHello Statalist, I have a general question about multiple imputations method in Stata. There are mu…
Compound double quotes for single quotesDear Statalisters, I'm wondering if there is a possibility like compound double quotes for single q…
Subscribe to:
Post Comments (Atom)
0 Response to Looping within a loop
Post a Comment