Currently i am fetching data based on below date filter manually.
Previous_Date>20191201 and Current_Date<20201201
I want take above date dynamically using macro.
Then next year it should be Previous_Date>20201201 and Current_Date<20211201 and it should go on for every year
I SERIOUSLY doubt that your code works, unless you have "dates" stored in a most unusable fashion. December 1st, 2019 must be written as "01dec2019"d to be a SAS date value.
Having said that, here's code that shows how to derive your dates from a given year:
%let year=2020;
data _null_;
call symputx("prevcut",mdy(12,1,&year. - 1));
call symputx("currcut",mdy(12,1,&year.));
run;
which you can then use to compare with dates stored in a dataset:
Previous_Date > &prevcut. and Current_Date < &currcut.
@Son_Of_Krypton wrote:
I don't want to use %let statement it should pick up the year from dataset and should increase by year when it will start running for next year
Is the year in a variable within the dataset, or is it part of the dataset name? If the latter, are those dataset names structured consistently, and how?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.