0
votes

I would like to "shortcut" this function of a macro variable

intnx('YEAR',"&starting_year"D,-5,'S'); 

with another macro variable. Is it possible ?

something like:

%let start = intnx('YEAR',"&starting_year"D,-5,'S'); 

Of course this code-line doesn't work.

2
Can you provide example values of STARTING_YEAR and the corresponding values of START that should result? Do you want the year or the first day of the year? Do you want it formatted as DATE9 string?Tom
STARTING_YEAR is a prompt like '20MAR1999' , START would be '20MAR1994' and yes date9 format.arj

2 Answers

3
votes

You can use %SYSFUNC() to call functions in macro code. You can use the optional format specification to control how the results is converted to the text that is stored in the macro variable.

So if you start with macro variable in DATE. format you could generate the date that was 5 years before that date like this:

%let start=%sysfunc(intnx(year,"&starting_date"d,-5,s),date9);

This would convert 20MAR1999 to 20MAR1994. Or it would convert 29FEB04 to 28FEB1999.

1
votes

%sysfunc lets you call regular SAS functions in the macro language. Perhaps something like (untested) :

%let start = %sysfunc(intnx(YEAR,"&starting_year"D,-5,S));