/* Firm age: firmage */
/* append st_date (start date) from crsp stocknames to 'getAge' dataset (needs to have permno and datadate) */
proc sql;
create table withAge
as select distinct a.*,
b.st_date, b.end_date
from getAge a
left join crsp.stocknames b
on a.permno = b.permno and
b.st_date <= a.datadate <= b.end_date;
quit;
/* compute firm age */
data withAge (drop = st_date end_date);
set withAge;
firmage=yrdif(st_date, datadate, 'ACT/ACT');
run;