DATA Step, Macro, Functions and more

SAS DATE ISSUED

Reply
New Contributor
Posts: 2

SAS DATE ISSUED

Hi All,

 

I m trying to do sas date function using sas macro and i need below output.

 

%let a= %sysfunc(intnx(day,%sysfunc(today()),-1),yymmdd10.);

 

Output

2017-10-26.

 

but need output should be .

'2017-10-26'

 

within the code.

 

Please guide me how would be do it.

PROC Star
Posts: 1,410

Re: SAS DATE ISSUED

data _null_;
   date=today()-1;
   format date yymmdd10.;
   put date;
run;
Super User
Posts: 10,623

Re: SAS DATE ISSUED

Where do you use the macro variable? Depending on the use, both the format and the quotes might not be necessary.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Trusted Advisor
Posts: 1,400

Re: SAS DATE ISSUED

If you have to do this in macro, you could precede and follow you expression with %str(%'), as in:

 

%let a=    %str(%')%sysfunc(intnx(day,%sysfunc(today()),1),yymmdd10.)%str(%');
%put &=a;
New Contributor
Posts: 2

Re: SAS DATE ISSUED

Thank a lots.
worked it.
Super User
Posts: 24,027

Re: SAS DATE ISSUED

Personally I'm not a fan of including quotes in macro variables, I prefer to leave them unquoted and then use with quotes as necessary. It makes them more versatile in the long run and allows for multiple uses.

Ask a Question
Discussion stats
  • 5 replies
  • 71 views
  • 0 likes
  • 5 in conversation