Cynthia,
I hope your post negates the gazillion or so programmers doing what they shouldn't do, but my original suggestion was based on an old SAS-L post I recalled where the opposite result was obtained.
My point: it sure helps to know, as part of one's learning, how semicolons can affect macros.
For example, try the following two runs (where the presence or absence of the semicolon is INSIDE the macro:)
%MACRO FUNC(MONTH);
SUBSTR(PUT(&MONTH,Z6.),1,4)*12 +
SUBSTR(PUT(&MONTH,Z6.),5,2)*1;
%MEND;
DATA TEST;
M1=200901; M2=200705;
DIFF=%FUNC(M1)-%FUNC(M2);
RUN;
which will, of course, result in an error, while the following one will run without any problem (other than, of course, the notes about converting text to numbers):
%MACRO FUNC(MONTH);
SUBSTR(PUT(&MONTH,Z6.),1,4)*12 +
SUBSTR(PUT(&MONTH,Z6.),5,2)*1
%MEND;
DATA TEST;
M1=200901; M2=200705;
DIFF=%FUNC(M1)-%FUNC(M2);
RUN;
I don't want to be too critical, but it would have been nice if the developers of built-in SAS macros had followed the same protocol that has been ingrained into the rest of us.
Art
... View more