BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
subrat1
Fluorite | Level 6

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
%LET YYQ =%SYSFUNC(QUOTE( %SYSFUNC(INTNX(QTR, %SYSFUNC(TODAY()), -1, E) , DATE9.)))D;

%put &YYQ ;

View solution in original post

5 REPLIES 5
LinusH
Tourmaline | Level 20
If you can live with " instead of ' (because it's easier to handle).
So, since macro variables is just text right off, just add it to right side of the %let statement.
The " will allow the macro function calls evaluate, ' won't.
Data never sleeps
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Patrick
Opal | Level 21

What about?

%LET YYQ = "%SYSFUNC(INTNX(QTR, %SYSFUNC(TODAY()), -1, E) , DATE9.)"d;
ballardw
Super User

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(&macrovar,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.

Ksharp
Super User
%LET YYQ =%SYSFUNC(QUOTE( %SYSFUNC(INTNX(QTR, %SYSFUNC(TODAY()), -1, E) , DATE9.)))D;

%put &YYQ ;

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1305 views
  • 4 likes
  • 6 in conversation