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!!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.