Hello everyone. Help me please.
I run those codes many times.
But sometimes it works well, but sometimes it doesn't work.
the error message is like this:
file table/rd/collapse/male_quad_dta.dta cannot be modified or erased; likely cause is read-only directory or file
But you know, whenever I run the codes, the error location is different.
More terrible fact is that I did it well before!! but now it does not work at all!!
Help me please!!
I will aprreciate if you can fix it.
thank you
use $outdata/klips1-26p_cleaned_SB, clear
keep if inrange(age,30,49)
drop pobs
bys pid: gen pobs=_n
bys pid: egen N=max(pobs)
keep if pobs==N
* region
*----------------------==---------------------------------------------------------
gen age14region_rural_noncapital = (age14region_noncapital==1 & age14region_rural==1 & age14region!=18) //
* control
*-------------------------------------------------------------------------------
gen edu_4somecol=(eduyrs>=15) if !mi(eduyrs)
gen edu_4col=(eduyrs>=16) if !mi(eduyrs) // excluding non-graduated
* spline
*-------------------------------------------------------------------------------
gen treat=(cbirthyr>=0)
gen ct=cbirthyr*treat
gen ct2=cbirthyr*(1-treat)
gen ct_sq=ct*ct
gen ct2_sq=ct2*ct2
** 1.1 collapsed data + age restriction+ newcl
*-------------------------------------------------------------------------------
global ctrl1 "i.age14region"
global ctrl2 "i.age14region age age_sq dadedu_somecol" //
global var "colatrm edu_somecol edu_4somecol edu_4col"
foreach fit in lin quad {
foreach sx in all male female {
foreach var in $var {
foreach i of numlist 13 15 20{
*append
if "`var'"=="colatrm" & `i'==13 {
local how replace
}
else {
local how append
}
* (1) region
reg `var' treat ${`fit'} $ctrl1 if inrange(cbirthyr,-`i',`i') ${`sx'}, vce (cluster cl_group)
estadd ysumm, mean
est save ${tab}/rd/collapse/bandwidth`i'/`var'_c1_`fit'_i, replace //1 all 2 male 3 female
outreg2 using ${tab}/rd/collapse/`sx'_`fit', dta `how' dec(3) adjr2 ///
cttop("band`i'") adds("Dep. var. mean", e(ymean), "Adjusted R-squared", e(r2_a)) adec(3) ///
drop(i.age14region) addtext(14y-old Region FE, YES)
* (2) age age_sq dadedu_somecol i.age14region
reg `var' treat ${`fit'} $ctrl2 if inrange(cbirthyr,-`i',`i') ${`sx'}, vce (cluster cl_group)
estadd ysumm, mean
est save ${tab}/rd/collapse/bandwidth`i'/`var'_c2_`fit', replace //1 all 2 male 3 female
outreg2 using ${tab}/rd/collapse/`sx'_`fit', dta append dec(3) adjr2 ///
cttop("band`i'") adds("Dep. var. mean", e(ymean), "Adjusted R-squared", e(r2_a)) adec(3) ///
drop(i.age14region) addtext(14y-old Region FE, YES)
}
}
}
}
I run those codes many times.
But sometimes it works well, but sometimes it doesn't work.
the error message is like this:
file table/rd/collapse/male_quad_dta.dta cannot be modified or erased; likely cause is read-only directory or file
But you know, whenever I run the codes, the error location is different.
More terrible fact is that I did it well before!! but now it does not work at all!!
Help me please!!
I will aprreciate if you can fix it.
thank you
use $outdata/klips1-26p_cleaned_SB, clear
keep if inrange(age,30,49)
drop pobs
bys pid: gen pobs=_n
bys pid: egen N=max(pobs)
keep if pobs==N
* region
*----------------------==---------------------------------------------------------
gen age14region_rural_noncapital = (age14region_noncapital==1 & age14region_rural==1 & age14region!=18) //
* control
*-------------------------------------------------------------------------------
gen edu_4somecol=(eduyrs>=15) if !mi(eduyrs)
gen edu_4col=(eduyrs>=16) if !mi(eduyrs) // excluding non-graduated
* spline
*-------------------------------------------------------------------------------
gen treat=(cbirthyr>=0)
gen ct=cbirthyr*treat
gen ct2=cbirthyr*(1-treat)
gen ct_sq=ct*ct
gen ct2_sq=ct2*ct2
** 1.1 collapsed data + age restriction+ newcl
*-------------------------------------------------------------------------------
global ctrl1 "i.age14region"
global ctrl2 "i.age14region age age_sq dadedu_somecol" //
global var "colatrm edu_somecol edu_4somecol edu_4col"
foreach fit in lin quad {
foreach sx in all male female {
foreach var in $var {
foreach i of numlist 13 15 20{
*append
if "`var'"=="colatrm" & `i'==13 {
local how replace
}
else {
local how append
}
* (1) region
reg `var' treat ${`fit'} $ctrl1 if inrange(cbirthyr,-`i',`i') ${`sx'}, vce (cluster cl_group)
estadd ysumm, mean
est save ${tab}/rd/collapse/bandwidth`i'/`var'_c1_`fit'_i, replace //1 all 2 male 3 female
outreg2 using ${tab}/rd/collapse/`sx'_`fit', dta `how' dec(3) adjr2 ///
cttop("band`i'") adds("Dep. var. mean", e(ymean), "Adjusted R-squared", e(r2_a)) adec(3) ///
drop(i.age14region) addtext(14y-old Region FE, YES)
* (2) age age_sq dadedu_somecol i.age14region
reg `var' treat ${`fit'} $ctrl2 if inrange(cbirthyr,-`i',`i') ${`sx'}, vce (cluster cl_group)
estadd ysumm, mean
est save ${tab}/rd/collapse/bandwidth`i'/`var'_c2_`fit', replace //1 all 2 male 3 female
outreg2 using ${tab}/rd/collapse/`sx'_`fit', dta append dec(3) adjr2 ///
cttop("band`i'") adds("Dep. var. mean", e(ymean), "Adjusted R-squared", e(r2_a)) adec(3) ///
drop(i.age14region) addtext(14y-old Region FE, YES)
}
}
}
}
