12-17-2013 09:38 AM
BPM = INTNX('Month',&Rundate,-1,'b'); /*first day last month*/
EPM = INTNX('Month',&Rundate,-1,'e'); /*last day last month*/
%put &pmb &pme ;
The above datastep will return a 5 digit number that represents the dates (ie 19663)
format last_month_begin last_month_end mmddyy10.;
I ran this datastep to convert the results from a number to an actual date format (ie 19663 becomes 11/1/2013)
Is there a way to avoid this datastep date1 and address the desired date formatting in the data null process instead?
12-17-2013 05:07 PM
Have you heard about date constants? They make date parameters so much easier to handle - they really are worth the effort of the learning.
They allow your code to look much more readable with proper dates rather than a number of days since 1960. Not just more readable but also much better for checking.
They work like:
WHERE dateVariable < "22dec2013"d
So it is really helpful that %SYSFUNC() can so easily provide the formatted dates like
%LET end_lastM = %SYSFUNC( INTNX( month, "&sysdate9"d, -1, E ), date9 ) ;
%LET beg_lastM = %SYSFUNC( INTNX( month, "&end_lastM"d, 0, B ), date9 ) ;
which might be used like
where tran_date between "&beg_lastM"d and "&end_lastM"