@CamRutherford, I quote your posts:
I'd want a macro because I reference these dates a lot
and:
How would I reference each date though?
You should be aware of two different terms: macro program and macro variables.
Within a macro program you can generate sas code according to arguments given.
Macro variables can be craeted in various ways: by a datastep or by %let statement.
The last can be either in or out of a macro program.
And be aware that macro variable can be global, available anywhere in your sas session or
local. ie available only inside a specific macro program.
In your case, you want several macro variables, each per different date.
You got some posts how to do it by a datastep.
The call symput statement assingns a value to a macro variable.
I quote here my code posted, leaving you to complete more assignments as you like:
data _NULL_;
/*=== calculate dates ===*/
dt = today();
dt_1y = intnx('year',dt,-1,'same');
dt_3m = intnx('month',dt,-3,'same');
dt_6m = intnx('month',dt,-6,'same');
dt_9m = intnx('month',dt,-9,'same');
dt_fpm = intnx('month',dt,-1,'beginning');
dt_lpm = intnx('month',dt,-1,'end'); /* or = toady() - day(today()); */
/*=== assign dates to macro variables ===*/
call symput('toady',left(dt));
call symput('dt_1y',left(dt_1y));
call symput('dt_3m',left(dt_3m));
...... /* choose your macro variable names and assign the dates calculated */
run;
%put &today &dt_3y &dt_3m;
Run the code and check the log. The numbers you got is the eqivalent to dates calculated.
As to the question how you use it, here is a demo:
data _null_;
today = &today;
put today ddmmyy10.;
dt_1y = &dt_1y;
put 'today last year = ' dt_1y ddmmyy10.;
tdr = &dt_3m;
put 'Today 3Mths ago = ' tdr date9.;
run;