I want to create a linktable for CRSP and Compustat data for GVkeys and Permno firm identifiers and have some problems with the different fiscal year formats the two databases (monthly vs yearly) use.
I've come so far as to input the Compustat fiscal year definition for the month and year of each Permno link start date (linkdt), resulting in one variable for month and one for year in the long format. But I don't know how to transform that now into a single variable in %tm format.
Any help?
Here is my code so far:
use "F:\...\20221215 CMM_GVKEY PERMNO links.dta"
rename LPERMNO permno
rename LPERMCO permco
drop gvkey_old
sort gvkey
rename LINKDT linkdt
rename LINKENDDT linkenddt
generate linkdt_month = month(linkdt)
replace linkdt_month = month(linkdt)-1 if day(linkdt)<15
generate linkdt_year = year(linkdt)
replace linkdt_year = year(linkdt)-1 if linkdt_month==0
replace linkdt_month = 12 if linkdt_month==0
I've come so far as to input the Compustat fiscal year definition for the month and year of each Permno link start date (linkdt), resulting in one variable for month and one for year in the long format. But I don't know how to transform that now into a single variable in %tm format.
Any help?
Here is my code so far:
use "F:\...\20221215 CMM_GVKEY PERMNO links.dta"
rename LPERMNO permno
rename LPERMCO permco
drop gvkey_old
sort gvkey
rename LINKDT linkdt
rename LINKENDDT linkenddt
generate linkdt_month = month(linkdt)
replace linkdt_month = month(linkdt)-1 if day(linkdt)<15
generate linkdt_year = year(linkdt)
replace linkdt_year = year(linkdt)-1 if linkdt_month==0
replace linkdt_month = 12 if linkdt_month==0
Comment