use "..\..\Data\COMPUSTAT 20180608.dta", clear
keep datacqtr gvkey apq cogsq
replace datacqtr = subinstr(datacqtr, "Q", "",.) 
destring datacqtr, replace 
duplicates drop datacqtr gvkey, force
gen year = floor(datacqtr/10)

gen dpoq = apq/cogsq * 365/4

bys gvkey year: egen dpo = mean(dpoq)

drop cogsq apq dpoq

save "compustat_c2c_computed.dta", replace
