11-23-2016 08:34 AM
I am trying to create a variable that equals the average of free cash flow (fcf) for years t-2 through t-4 for each firm (cusip). This code works beautifully on my quarterly dataset, but I cannot figure out the tweak to make it work on my annual dataset. It returns "." for each observation. Any help would be lovely!!!
I am using the code:
create table rollingavg_fcf as
select *,(select mean(fcf) from trial where year between intnx('year',a.year,-4) and intnx('year',a.year,-2) and cusip=a.cusip) as rollingavg_fcf
from trial as a;
11-23-2016 08:40 AM
Maybe start with a search on the forums, there is some 50 topics which come up for rolling average:
11-23-2016 08:53 AM
If year is not a SAS date, but a numerical value like 2016, you can't (reasonably) apply the intnx function to it.