I'm stuck with an old problem (using loop for regression). The variables are smoking (DV), country, education and income. The goal is to regress 'smoking' on 'education' and 'income' for all seven countries, and to save the ORs for each country. I tried the following code, which is not producing anything:
Code:
local saving n.dta foreach n in ` country' { statsby _b, by(country): logit smoker i.education i.income eststo }
Thanks in advance for you insights. Here is the dataex:
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(country education income smoker)
4 0 3 1
2 0 3 1
4 0 3 1
5 0 3 1
4 0 3 1
3 0 3 1
7 0 3 1
3 1 4 1
3 0 4 1
5 0 4 1
3 0 4 1
2 0 4 1
4 0 4 1
5 0 2 1
4 0 2 1
7 0 3 1
1 1 3 1
7 0 2 1
2 0 2 1
6 0 2 0
1 2 2 1
7 0 2 1
3 0 2 1
3 0 2 1
6 0 3 1
2 0 3 1
5 0 2 1
1 0 2 1
5 0 2 1
5 0 2 0
7 0 2 1
7 0 2 1
1 0 2 .
7 0 2 1
1 0 2 .
3 0 2 1
4 0 2 1
4 0 2 1
2 0 2 .
1 0 2 .
4 0 2 1
6 0 3 1
6 0 3 1
6 0 3 1
1 0 3 .
2 0 3 1
7 0 2 0
3 0 2 1
1 0 2 1
1 0 2 .
1 0 3 .
3 0 4 1
7 0 4 1
1 0 4 .
2 0 4 1
2 0 1 1
1 0 3 1
1 0 3 1
3 0 1 1
3 0 2 1
2 0 3 1
1 0 3 1
1 0 3 .
7 0 2 1
3 0 2 1
4 0 3 1
3 0 3 1
2 0 3 1
2 0 3 1
3 0 3 1
2 0 3 .
1 0 3 .
5 0 1 1
2 0 1 1
5 0 2 1
2 0 2 1
7 0 1 1
2 0 1 1
1 0 1 1
7 0 1 1
1 0 1 .
1 1 1 .
3 0 1 1
3 0 1 1
4 0 1 1
4 0 1 1
2 0 1 1
1 0 1 1
3 0 1 1
5 0 1 1
1 0 1 1
5 0 1 1
3 2 2 1
5 0 1 1
4 0 1 1
5 0 1 1
2 0 1 .
1 0 1 .
2 0 3 1
2 0 3 1
end
0 Response to Using loop for regression and saving results as a new variable
Post a Comment