I want to create one macro for the last date of the month with quotation mark and with D suffix,
'31MAR2016'D |
'30JUN2016'D |
'30SEP2016'D |
'31DEC2016'D |
'31MAR2017'D |
I want to create another macro only with quotation mark...like:
'31MAR2016' |
'30JUN2016' |
'30SEP2016' |
'31DEC2016' |
'31MAR2017' |
I am trying with this:
%LET
YYQ = %SYSFUNC(INTNX(QTR, %SYSFUNC(TODAY()), -1, E) , DATE9.);
But this does not give quotation mark and D suffix
%LET YYQ =%SYSFUNC(QUOTE( %SYSFUNC(INTNX(QTR, %SYSFUNC(TODAY()), -1, E) , DATE9.)))D; %put &YYQ ;
Why? Macro language is for generating text, it has no data constructs or data processing functionality. It would be far better to use Base SAS, datasets and such like for processing data. If you provide information on what you are trying to do we can provide code.
What about?
%LET YYQ = "%SYSFUNC(INTNX(QTR, %SYSFUNC(TODAY()), -1, E) , DATE9.)"d;
I would reconsider this entirely, especially for the first part.. The only place that you need "01MAR2016"D or similar would be for date literals. The actual integer values will work just as well. The literal form is so us humans understand what the code is doing instead of trying to make the conversion from 20514.
Such as
%let YYQ = %SYSFUNC(INTNX(QTR, %SYSFUNC(TODAY()), -1, E));
data _null_;
x=&yyq;
put "The target date is" +1 x date9.;
run;
Any place you would then need '30Mar2016' would very likey work with put(¯ovar,date9.) <Note: no quote for integer looking text from above.
My experience with putting quotes into SAS macro variables is that it almost never works well in the long run or I spend way too much time getting the logic to work, especially for complex code with many variables.
%LET YYQ =%SYSFUNC(QUOTE( %SYSFUNC(INTNX(QTR, %SYSFUNC(TODAY()), -1, E) , DATE9.)))D; %put &YYQ ;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.