Hello, can someone please help me to create macro variables for dates (in format 09Dec15) from today-2 to last year same date?
so like i want to create macro variable
date1 which would resolve to 07Dec14
date2=08Dec14
date3=09Dec14
.
.
.
date366=07Dec15
Thank you....
For that comparison you do not need any macro variables, just a data set with the target dates and then compare.
data basedates;
start = '07DEC2014'd;
do date=start to (intnx('year',Start,-1,'Same') ) by -1;
output;
end;
drop start;
format date date9.;
run;
proc sql;
title "Dates in base not occurring in comparison set";
select date from basedates
except
select distinct date from comparison;
quit;
This does what you've asked.
data _null_;
start = '07DEC2014'd;
do date=start to (intnx('year',Start,-1,'Same') ) by -1;
name=cats('date',start-date+1);
call symputx(name,put(date,date7.));
end;
run;
Thank You Ballardw, but not sure how it creartes 366 macro variables, date1 to date366, which would resolves to 07dec14 to 07dec15.
Also, i want to create this everyday, so tomorrow, 366 macro variables, date1 to date366, supposed to resolve to 08dec14 to 08dec15
thanks for your time....
I question what you're doing downstream with this, I feel that there's likely a better way.
You can adjust @ballardw code by changing the start to
start=today();
I have one sas dataset wich has last 1 yr history data in it and it used to gets update on daily bases. some times we miss some date data in it. so i want to know which date has missed in b/w.
to do that i am thinking to create macro variable everyday for last 1 year and check against distinct date from that history dataset.
For that comparison you do not need any macro variables, just a data set with the target dates and then compare.
data basedates;
start = '07DEC2014'd;
do date=start to (intnx('year',Start,-1,'Same') ) by -1;
output;
end;
drop start;
format date date9.;
run;
proc sql;
title "Dates in base not occurring in comparison set";
select date from basedates
except
select distinct date from comparison;
quit;
Thanks Ballardw and Reeza....
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.