data fflib.Mnme_all;
set fflib.me_all;
if eod2=0 then set fflib.me_all (firstobs=2 keep=date rename=(date=nxt_date)) end=eod2;
else nxt_date='31dec2030'd;
if intck('month',date,nxt_date)>0;
run;
I wish to filter only December data. I am not sure what's the code for it and require some assistance. Thank you!
You have a time series of data, and your current program captures the last value in each month. (BTW, I see "fflib" and some familiar variable names, is this fama-french data?).
By "I wish to filter only December data.", are you really only trying to get the last value in each year? If so, then instead of
if intck('month',date,nxt_date)>0;
use
if intck('year',date,nxt_date)>0;
Also you can use a MERGE statement to simplify your program instead of two SET statements (one conditional). It's a bit neater.
data fflib.mnme_all:
merge fflib.me_all
fflib.me_all (firstobs=2 keep=date rename=(date=nxt_date));
if intck('year',date,next_date)>0;
run;
But finally, your data appears to be monthly. So (1) your filter eliminated no data, and (2) you can use @ChrisNZ 's suggestion to use a WHERE statement with the MONTH function:
data fflib.mnme_all:
set fflib.me_all (where=(month(date)=12);
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.