Hello, everyone. I want to receive the 25 charts in the once. ( 5 row and 5 columns ) . Because it represents the combination at a 5-time horizon, But at the end, it gives me 25 PDFs separately.
and then :
and :
Thank you so much.
Regards,
Code:
clear
foreach v in "totalfertility" {
forvalues x = 1/5 {
forvalues y = 1/5 {
foreach vart in "0" "1" "2" "3" "4" "5" {
cd "C:\Users\KHATEREH\Desktop\MyProject/`v'"
use "C:\Users\KHATEREH\Desktop\charts A\xtscc-correct-dataset.dta"
xi: statsby _b _se e(r2_a), clear: xtscc d`vart'`v' l(0/`y')dum_recession l(1/`x')d0`v' i.year,fe
foreach var in dum_recession {
gen t_`var' = _b_`var'/_se_`var'
gen time = "obs`vart'"
save `y'`x'`v'`vart'.dta, replace
}
}
}
}
}
Code:
clear
foreach v in "totalfertility" {
forvalues x = 1/5 {
forvalues y = 1/5 {
use "C:\Users\KHATEREH\Desktop\MyProject/`v'/`y'`x'`v'0.dta"
foreach var in "1" "2" "3" "4" "5" {
append using "C:\Users\KHATEREH\Desktop\MyProject/`v'/`y'`x'`v'`var'.dta"
*drop _merge
}
gen date_string = substr(time, 4, 2)
destring date_string, gen(year)
keep year _b_dum_recession _se_dum_recession t_dum_recession
order year _b_dum_recession _se_dum_recession t_dum_recession
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_recession=0 if time2==-1
replace _se_dum_recession=0 if time2==-1
replace t_dum_recession=0 if time2==-1
bysort label (year) : gen low = _b_dum_recession-(_se_dum_recession*1.645)
bysort label (year) : gen high = _b_dum_recession+(_se_dum_recession*1.645)
gen a=0
*a=0 is for charts
save "C:\Users\KHATEREH\Desktop\MyProject/`y'`x'`v'all.dta", replace
}
}
}
Code:
cd "C:\Users\KHATEREH\Desktop\MyProject/"
forvalues x = 1/5 {
forvalues y = 1/5 {
clear
use "C:\Users\KHATEREH\Desktop\MyProject/`y'`x'totalfertilityall.dta"
twoway rarea high low time2, astyle(ci) || ///
line _b_dum_recession time2, mstyle(p1) || ///
line a time2, mstyle(p1) lpattern(dash) lwidth(vthin) lcolor(gs0) ///
xtitle("Periods after Pandemic Recession") ytitle("level changes totalfertilitry") ylabel(,alternate) xlabel(-1(1)5) title(lag `x'_`var'_lag`y'shock) legend(off) saving("`var'", replace)
graph export `y'`x'totalfertilitry.pdf, replace
}
}
Regards,

Comment