Hello,
I'm looking to create prev month beg and end month datetime as macro variable in the below format using today's date. Could someone please help me?
%Let PBOM_Dte = 2012-08-01 00:00:00;
%Let PEOM_Dte = 2012-08-31 23.59:59;
Thanks in advance for your help!
proc format;
picture fmt
other='%Y-%0m-%0d %0H:%0M:%0S'(datatype=datetime);
run;
%let PBOM_Dte = %sysfunc(intnx(dtmonth,%sysfunc(datetime()),-1,b),fmt21. );
%put &PBOM_Dte ;
data _null_;
call symputx('pbom_dte',catx(' ',put(intnx('month',today(),-1,'b'),yymmdd10.),'00:00:00'));
call symputx('peom_dte',catx(' ',put(intnx('month',today(),-1,'e'),yymmdd10.),'23:59:59'));
run;
%put &pbom_dte;
%put &peom_dte;
/* log file */
65 %put &pbom_dte;
2012-08-01 00:00:00
66 %put &peom_dte;
2012-08-31 23:59:59
proc format;
picture fmt
other='%Y-%0m-%0d %0H:%0M:%0S'(datatype=datetime);
run;
%let PBOM_Dte = %sysfunc(intnx(dtmonth,%sysfunc(datetime()),-1,b),fmt21. );
%put &PBOM_Dte ;
Hi Vicky,
Try this..some thing similar to Linlins code...
data _null_;
call symputx('pbom_dte',put(dhms(intnx('month',today(),-1,'b'),00,00,00),nldatm.));
call symputx('peom_dte',put(dhms(intnx('month',today(),-1,'e'),23,59,59),nldatm.));
run;
%put &pbom_dte;
%put &peom_dte;
Thanks,
Shiva
All the three answers worked. Thanks to Ksharp,Shiva & Linlin!!
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.