David and Cynthia have explained some risks of the original approach and a better way of dealing with the information through the data step.
Having some experience of implementing batch processes with similar need of last month's date, I can offer a reduced solution that appears almost intuitive.
If you seek a simple statement that delivers "last month" in some format, consider these alternatives all of which use
the "interval next" function, INTNX() applied to
the automatic macro variable &sysDate (which provides the SAS session start date - a date you can usually rely on in batch processing).
What makes the following alternatives different, is just the format of the date info:
e.g. NOV2007
%let LastMon = %sysfunc( intnx( month "&sysdate"d, -1 ), monyy7 );
e.g. NOV07
%let LastMon = %sysfunc( intnx( month "&sysdate"d, -1 ), monyy5 );
e.g. 11-2007
%let LastMon = %sysfunc( intnx( month "&sysdate"d, -1 ), mmyyD7 );
e.g. 2007.11
%let LastMon = %sysfunc( intnx( month "&sysdate"d, -1 ), yymmP6 );
e.g. 0711
%let LastMon = %sysfunc( intnx( month "&sysdate"d, -1 ), yymmD4 );
e.g. 30NOV2007
%let LastMon = %sysfunc( intnx( month "&sysdate"d, -1, e ), date9 );
e.g. 20071130
%let LastMon = %sysfunc( intnx( month "&sysdate"d, -1, e ), yymmddN8 );
There are many more date formats: look for Date and Time in Formats by Category in SAS Online-Doc at
http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001263753.htm.
&SYSDATE is described in the Macro Language Dictionary at
http://support.sas.com/onlinedoc/913/getDoc/en/mcrolref.hlp/a000489463.htm.
For description of function INTNX(), see
http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a000212700.htm.
For invoking base SAS functions %SYSFUNC() is described at
http://support.sas.com/onlinedoc/913/getDoc/en/mcrolref.hlp/z3514sysfunc.htm.
The most complete list of formats can be found in the internal dictionary table of formats which can be used as SAS System data set SASHELP.VFORMATS.
Seasons Greetings
PeterC