DATA Step, Macro, Functions and more

Macro code

Reply
N/A
Posts: 0

Macro code

Hi,

I need to create a monthly report. For that i have created a macros,

data _null_;
call symput ('begindt',intnx('MONTH',today(),-4));
call symput ('enddt',intnx('MONTH',today(),-3));
call symput ('rdate',put(today(),date9.));
run;

If run this code , %put &begindt ; am getting SAS date.
If i want to see in ddmmyyyy means how to convert the code ?

Pls anyone let me know..

Thanks,
sudha
Valued Guide
Posts: 634

Re: Macro code

Posted in reply to deleted_user
Use %SYSFUNC with the PUTN function.
[pre]
%let begindt = 18234;
%put %sysfunc(putn(&begindt,ddmmyy10.));[/pre]
N/A
Posts: 0

Re: Macro code

Hi ,

Thanks for your reply...
But if i ran that syntax

%put %sysfunc(putn(&begindt,ddmmyy10.));

am getting an output as 01/01/1960..

But i need to get an output as 09/01/2010.

please let me know..

Thanks,
sudha
Super Contributor
Super Contributor
Posts: 365

Re: Macro code

Posted in reply to deleted_user
Hello Sudcha,

I tried ArtC's suggestion on my computer. This code works as expected:
[pre]
data _null_;
call symput ('begindt',intnx('MONTH',today(),-4));
run;
%put begindt=%trim(&begindt);
%put %sysfunc(putn(&begindt,ddmmyy10.));
[/pre]
Sincerely,
SPR
N/A
Posts: 0

Re: Macro code

Yes am getting an exact output what am expecting !!

Thank you !!!
SAS Employee
Posts: 58

Re: Macro code

Posted in reply to deleted_user
You can find out more about using SAS dates here. I hope this helps.

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a002200738.htm
Ask a Question
Discussion stats
  • 5 replies
  • 127 views
  • 0 likes
  • 4 in conversation