Hi:
%LET is merely assigning TEXT strings to &PERIOD2, as shown in the SAS log below:
[pre]
111 %let period1 = '1aug2010:0:0'dt; * the reporting month we're
111! looking at;
112 %let period2 = '1jul2010:0:0'dt; * the month before the
112! reporting month we're looking at;
113 %let period3 = '1jun2010:0:0'dt; * 2 months before reporting
113! month;
114 %let period4 = '1sep2010:0:0'dt; *the month after the reporting
114! month we're looking at;
115
116 %put *** before INTNX:;
*** before INTNX:
117 %put period1 = &period1;
period1 = '1aug2010:0:0'dt
118 %put period2 = &period2;
period2 = '1jul2010:0:0'dt
119 %put period3 = &period3;
period3 = '1jun2010:0:0'dt
120 %put period4 = &period4;
period4 = '1sep2010:0:0'dt
121 %put *** *** *** *** ***;
*** *** *** *** ***
122
123
124 %let period2 = intnx('month',&period1., -1);
125 %put *** after INTNX 1:;
*** after INTNX 1:
126 %put period2 = &period2;
period2 = intnx('month','1aug2010:0:0'dt, -1)
127
128 %let period2 = intnx('month',&period1, -1);
129 %put *** after INTNX 2:;
*** after INTNX 2:
130 %put period2 = &period2;
period2 = intnx('month','1aug2010:0:0'dt, -1)
131
132 %let period2 = intnx('month','&period1'dt, -1);
133 %put *** after INTNX 3:;
*** after INTNX 3:
134 %put period2 = &period2;
period2 = intnx('month','&period1'dt, -1)
[/pre]
So if you want the INTNX function to actually be INVOKED and -do- something, you would need to use the %SYSFUNC macro function in order to assign a different value to a new macro variable. For example, a simpler date-related function shows how to extract the month, day and year from a macro variable value that represents a date. Note the "&bday"d construct in the date function usage -- I don't favor "pre-quoting" macro variable values when the values are assigned:
[pre]
135 %let bday = 15nov1950;
136
137 %let mm = %sysfunc(month("&bday"d));
138 %let bd = %sysfunc(day("&bday"d));
139 %let yr = %sysfunc(year("&bday"d));
140
141 %put month of bday = &mm;
month of bday = 11
142 %put day of bday = &bd;
day of bday = 15
143 %put year of bday = &yr;
year of bday = 1950
[/pre]
cynthia