Hello, I try to use the loop for my analysis and save them and draw charts.
so I receive an error several times. (If I put `v' in the directory part )

Code:
clear
foreach v in "lntot_birth" "ltotalfertility" {
foreach vart in "0" "1" "2" "3" "4" "5" {
cd "C:\Users\KHATEREH\Desktop\MyProject\`v'"
use "C:\Users\KHATEREH\Desktop\dataset_fertility_paper (2).dta"
statsby _b _se e(r2_a), clear: reghdfe f(`vart').`v' l(0/2)dum_recession l(1/2)`v' , absorb( i.ifscode i.year) vce(cluster ifscode)

foreach var in dum_recession {
    gen t_`var' = _b_`var'/_se_`var'
    gen time = "obs`vart'"
save `v'`vart'.dta, replace
    }
    }
    }
unable to change to C:\Users\KHATEREH\Desktop\MyProject`v'
r(170);
if not I receive 12 dta files but them again for drawing and merging them I receive an error.


Code:
foreach v in "lntot_birth" "ltotalfertility" {
    
use "C:\Users\KHATEREH\Desktop\MyProject\0.dta\`v'"
foreach var in  "1" "2" "3" "4" "5" {
append using "C:\Users\KHATEREH\Desktop\MyProject\`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\all", replace
}
Code:
file C:\Users\KHATEREH\Desktop\MyProject\0.dta`v' not found
I hope I receive your advices.

Thank you so much.

regards,