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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.