REPRO-Bench / 16 /replication_package /programs /shortjobs_firmsize.do
anonymous-submission-acl2025's picture
add 16
b4ae6c9
set more off
clear
// cd "G:\My Drive\Research\ShortJobs\AEJM\Final"
**Extract the data from the raw qwi files (comment out this next line if the qwi_fs.dta data file has already been created)
qui do shortjobs_qwi_fs
use qwi_fs, replace
keep if sex == 0
drop sex
keep if agegrp=="A00"
drop agegrp
keep if industry=="00"
drop industry
drop if firmsize==0
**Generate variables of interest
sort geography firmsize year quarter
egen cell=group(firmsize year quarter)
** aggregate over geography
bysort cell: egen allhira=total(hira) // hires in the quarter
bysort cell: egen allhiras=total(hiras) // "stable" hires, workers in second quarter of employment
bysort cell: egen allhiraend=total(hiraend) // all hires that also survive into second quarter
bysort cell: egen allemp=total(emp) // beginning of quarter employment (had earnings last quarter and this quarter)
bysort cell: egen allempend=total(empend) // end of quarter employment (have earnings this quarter and next quarter)
bysort cell: egen allemptot=total(emptotal) // total count of people employed in the quarter
bysort cell: egen allsep=total(sep) // total separations
bysort cell: egen allsepbeg=total(sepbeg) // total separations of employment spells that existed in previous quarter
bysort cell: keep if _n==1
drop geography
egen cellid=group(firmsize)
generate employ=(allemp+allempend)/2
generate oneqsepsrate1=(allhira-allhiraend)/employ // spells that begin and end in the same quarter, as fraction of average of beginning and end employment
generate oneqsepsrate=(allhira-allhiraend)/allemptot // spells that begin and end in the same quarter, as fraction of total count of employment spells in the quarter
generate oneqhazrate=(allhira-allhiraend)/allhira // fraction of all hires in the quarter that also end in the quarter
generate twoplussepsrate=(allsepbeg)/allemptot //separations among spells with 2+ quarters of tenure, as fraction total count of employment spells in the quarter
generate twoplushazrate=(allsepbeg)/(allemptot-allhira) //separations among spells with 2+ quarters of tenure, as fraction of all such spells
xtset cellid time
generate twoqsepsrate=(L.allhiraend-allhiras)/allemptot //spells that separate by end of second quarter (all that started two quarters ago, minus the ones that we know continue past current quarter), as fraction of total count employment spells in quarter
generate twoqhazrate=(L.allhiraend-allhiras)/L.allhiraend // spells that separate by end of second quarter, as fraction of spells that have lasted two quarters
generate threeplussepsrate=(allsep-(L.allhiraend-allhiras)-(allhira-allhiraend))/allemptot //separations among spells that have lasted three or more quarters, as fraction of total count of employment spells in the quarter
generate threeplushazrate=(allsep-(L.allhiraend-allhiras)-(allhira-allhiraend))/(allemptot-L.allhiraend-allhira) //separations among spells that have lasted three or more quarters, as fraction of all such spells
generate sepsrate=allsep/allemptot // overall separation rate
generate hirerate1=allhira/employ // hires as a fraction of average of beginning and end employment
generate hirerate=allhira/allemptot // hires as a fraction of total count of employmen spells in the quarter
drop if time<=1998*4+4 | time>2018*4
**Seasonally adjust by regressing on quarterly dummies
set matsize 2000
quietly{
generate oneqsepsrate1sa=.
generate oneqsepsratesa=.
generate oneqhazratesa=.
generate twoplussepsratesa=.
generate twoplushazratesa=.
generate twoqsepsratesa=.
generate twoqhazratesa=.
generate threeplussepsratesa=.
generate threeplushazratesa=.
generate sepsratesa=.
generate hirerate1sa=.
generate hireratesa=.
sort cell date
by cell: egen oneqsepsrate1means=mean(oneqsepsrate1)
by cell: egen oneqsepsratemeans=mean(oneqsepsrate)
by cell: egen oneqhazratemeans=mean(oneqhazrate)
by cell: egen twoplussepsratemeans=mean(twoplussepsrate)
by cell: egen twoplushazratemeans=mean(twoplushazrate)
by cell: egen twoqsepsratemeans=mean(twoqsepsrate)
by cell: egen twoqhazratemeans=mean(twoqhazrate)
by cell: egen threeplussepsratemeans=mean(threeplussepsrate)
by cell: egen threeplushazratemeans=mean(threeplushazrate)
by cell: egen sepsratemeans=mean(sepsrate)
by cell: egen hirerate1means=mean(hirerate1)
by cell: egen hireratemeans=mean(hirerate)
forvalues i=1/5{ // there are 5 firmsize cells
reg oneqsepsrate1 i.quarter if cellid==`i'
predict double sa, residual
replace oneqsepsrate1sa=sa+oneqsepsrate1means if cellid==`i'
drop sa
reg oneqsepsrate i.quarter if cellid==`i'
predict double sa, residual
replace oneqsepsratesa=sa+oneqsepsratemeans if cellid==`i'
drop sa
reg oneqhazrate i.quarter if cellid==`i'
predict double sa, residual
replace oneqhazratesa=sa+oneqhazratemeans if cellid==`i'
drop sa
reg twoplussepsrate i.quarter if cellid==`i'
predict double sa, residual
replace twoplussepsratesa=sa+twoplussepsratemeans if cellid==`i'
drop sa
reg twoplushazrate i.quarter if cellid==`i'
predict double sa, residual
replace twoplushazratesa=sa+twoplushazratemeans if cellid==`i'
drop sa
reg twoqsepsrate i.quarter if cellid==`i'
predict double sa, residual
replace twoqsepsratesa=sa+twoqsepsratemeans if cellid==`i'
drop sa
reg twoqhazrate i.quarter if cellid==`i'
predict double sa, residual
replace twoqhazratesa=sa+twoqhazratemeans if cellid==`i'
drop sa
reg threeplussepsrate i.quarter if cellid==`i'
predict double sa, residual
replace threeplussepsratesa=sa+threeplussepsratemeans if cellid==`i'
drop sa
reg threeplushazrate i.quarter if cellid==`i'
predict double sa, residual
replace threeplushazratesa=sa+threeplushazratemeans if cellid==`i'
drop sa
reg sepsrate i.quarter if cellid==`i'
predict double sa, residual
replace sepsratesa=sa+sepsratemeans if cellid==`i'
drop sa
reg hirerate1 i.quarter if cellid==`i'
predict double sa, residual
replace hirerate1sa=sa+hirerate1means if cellid==`i'
drop sa
reg hirerate i.quarter if cellid==`i'
predict double sa, residual
replace hireratesa=sa+hireratemeans if cellid==`i'
drop sa
}
}
save shortjobs_fs, replace
sort cellid time
by cellid: generate oneqsepsratesa_first=(oneqsepsratesa[1]+oneqsepsratesa[2]+oneqsepsratesa[3]+oneqsepsratesa[4])/4
by cellid: generate oneqsepsratesa_last=(oneqsepsratesa[_N]+oneqsepsratesa[_N-1]+oneqsepsratesa[_N-2]+oneqsepsratesa[_N-3])/4
by cellid: generate hireratesa_first=(hireratesa[1]+hireratesa[2]+hireratesa[3]+hireratesa[4])/4
by cellid: generate hireratesa_last=(hireratesa[_N]+hireratesa[_N-1]+hireratesa[_N-2]+hireratesa[_N-3])/4
by cellid: keep if _n==1
input str16 fs_label
"0-19"
"20-49"
"50-249"
"250-499"
"500+"
graph twoway (scatter oneqsepsratesa_last oneqsepsratesa_first in 1/5, mlabel(fs_label) xtitle("1999 One quarter incidence rate (q{sub:1})") ytitle("2017 One quarter incidence rate (q{sub:1})")) (function y = x, range(.04 .14) lcolor(black) legend(off))
graph rename oneqseps_firstlast_firmsize, replace
graph export oneqseps_firstlast_firmsize.pdf, name(oneqseps_firstlast_firmsize) as(pdf) replace
graph twoway (scatter hireratesa_last hireratesa_first in 1/5, mlabel(fs_label) xtitle("1999 Hires rate (h)") ytitle("2017 Hires rate (h)")) (function y = x, range(.14 .3) lcolor(black) legend(off))
graph rename hirerate_firstlast_firmsize, replace
graph export hirerate_firstlast_firmsize.pdf, name(hirerate_firstlast_firmsize) as(pdf) replace