Z2 will not drop the leading zero. How are you using the macro variable?
But if you try to apply the Z2 format to a date you should get ** unless the date is within the first 100 days of 1960.
If you want the month value you need ask for that explicitly. You could try using MMDDYY format and just take the first two characters.
Also don't use SYSDATE as it only includes 2 digit years. You should either Use SYSDATE9 or call the DATE() , also known as the TODAY() function, to get the current date instead of the date when your SAS session started.
1135 %put %sysfunc(putn(7,z2.));
07
1136 %put %sysfunc(intnx(month.1,"&sysdate9"d,-6),mmddyy10.);
07/01/2019
1137 %put %substr(%sysfunc(intnx(month.1,"&sysdate9"d,-6),mmddyy10.),1,2);
07
1138 %put %sysfunc(month(%sysfunc(intnx(month.1,"&sysdate9"d,-6))),z2.);
07
... View more