clear
foreach v in "rate_fer1519" {
foreach vart in "0" "1" "2" "3" "4" "5" {
cd "D:\Users\alimm\Desktop\fertility"
use "D:\Users\alimm\Desktop\loops excersis e\loop_ex\loop_send.dta"
statsby _b _se e(r2_a), clear: reg f(`vart').`v' l(0/2)dum_pan l(1/2)`v' i.ifscode i.year, vce(cluster ifscode)
foreach var in dum_pan {
gen t_`var' = _b_`var'/_se_`var'
gen time = "obs`vart'"
save `vart', replace
}
}
}
***
clear
foreach v in "rate_fer1519" {
use "D:\alimm\Desktop\fertility\0.dta"
foreach var in "1" "2" "3" "4" "5" {
append using "D\Users\alimm\Desktop\fertility\`var'.dta"
*drop _merge
}
gen date_string = substr(time, 4, 2
destring date_string, gen(year)
keep year _b_dum_pan] _se_dum_pan t_dum_pan
order year _b_dum_pan _se_pand_epis t_dum_pan
gen label="all"
bysort label (year) : gen first = _n == _N-5
**expand only the first obs
expand 2 if first==1
**** generate the new time variable
bysort label (year) :gen time2 = _n-2
***recode the variables
replace _b_dum_pan=0 if time2==-1
replace _se_dum_pan=0 if time2==-1
replace t_dum_pan=0 if time2==-1
bysort label (year) : gen low = _b_dum_pan-(_se_dum_pan*1.645)
bysort label (year) : gen high = _b_dum_pan+(_se_dum_pan*1.645)
gen a=0
*a=0 is for charts
save "D:\Users\alimm\Desktop\fertility\all", replace
}
foreach v in "rate_fer1519" {
foreach vart in "0" "1" "2" "3" "4" "5" {
cd "D:\Users\alimm\Desktop\fertility"
use "D:\Users\alimm\Desktop\loops excersis e\loop_ex\loop_send.dta"
statsby _b _se e(r2_a), clear: reg f(`vart').`v' l(0/2)dum_pan l(1/2)`v' i.ifscode i.year, vce(cluster ifscode)
foreach var in dum_pan {
gen t_`var' = _b_`var'/_se_`var'
gen time = "obs`vart'"
save `vart', replace
}
}
}
***
clear
foreach v in "rate_fer1519" {
use "D:\alimm\Desktop\fertility\0.dta"
foreach var in "1" "2" "3" "4" "5" {
append using "D\Users\alimm\Desktop\fertility\`var'.dta"
*drop _merge
}
gen date_string = substr(time, 4, 2
destring date_string, gen(year)
keep year _b_dum_pan] _se_dum_pan t_dum_pan
order year _b_dum_pan _se_pand_epis t_dum_pan
gen label="all"
bysort label (year) : gen first = _n == _N-5
**expand only the first obs
expand 2 if first==1
**** generate the new time variable
bysort label (year) :gen time2 = _n-2
***recode the variables
replace _b_dum_pan=0 if time2==-1
replace _se_dum_pan=0 if time2==-1
replace t_dum_pan=0 if time2==-1
bysort label (year) : gen low = _b_dum_pan-(_se_dum_pan*1.645)
bysort label (year) : gen high = _b_dum_pan+(_se_dum_pan*1.645)
gen a=0
*a=0 is for charts
save "D:\Users\alimm\Desktop\fertility\all", replace
}
0 Response to receiving different error among using loop and using do file
Post a Comment