I Ksharp, I actually wanted to make it dynamic so that at any given month when I will run my code, it will grab/filter the data until the last date of previous month of every year of the date field. DATA have; INPUT Date Course_ID $4.; INFORMAT Date Date9.; FORMAT Date Date9.; DATALINES; 05Jan2018 ENG1 16Jan2017 Bio2 09Dec2016 Che1 15Jan2018 Bio1 11MAY2015 Eng2 12Mar2016 Phy2 20May2018 Che1 ; PROC PRINT NOOBS; RUN; I have written the following code, but can really make it work at the end. Can you please help. Thanks. DATA want; SET have; Y0_FYb=YEAR(intnx('YEAR.4',date,0)); Y0_FYe=YEAR(intnx('YEAR.4',date,0,'e')); Y0_fromdate=intnx('year.4',date,0,'b'); Y0_todate=intnx('MONTH',date,-1,'e'); Y1P_FY=YEAR(intnx('YEAR.4',date,0)); Y1P_fromdate=intnx('year.4',date,0,'b'); Y1P_todate=intnx('MONTH',date,-1,'e'); Rep_ToMonth=intnx('MONTH', date , -1, 'e'); fy2 = COMPRESS(Y0_FYb||"-"||Y0_FYe); FORMAT Y0_fromdate Y0_todate Rep_ToMonth date date9.; PROC PRINT NOOBS; RUN; DATA Final; SET want; WHERE Rep_ToMOnth >= intnx('MONTH', %SYSFUNC(today()), -1, 'e'); RUN; PROC PRINT NOOBS; RUN;
... View more