<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: %let doesn't work with another macro variable?? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/let-doesn-t-work-with-another-macro-variable/m-p/18494#M3642</link>
    <description>Hi:&lt;BR /&gt;
  %LET is merely assigning TEXT strings to &amp;amp;PERIOD2, as shown in the SAS log below:&lt;BR /&gt;
[pre]&lt;BR /&gt;
111  %let period1 = '1aug2010:0:0'dt; * the reporting month we're&lt;BR /&gt;
111! looking at;&lt;BR /&gt;
112  %let period2 = '1jul2010:0:0'dt; * the month before the&lt;BR /&gt;
112! reporting month we're looking at;&lt;BR /&gt;
113  %let period3 = '1jun2010:0:0'dt; * 2 months before reporting&lt;BR /&gt;
113! month;&lt;BR /&gt;
114  %let period4 = '1sep2010:0:0'dt; *the month after the reporting&lt;BR /&gt;
114! month we're looking at;&lt;BR /&gt;
115&lt;BR /&gt;
116  %put *** before INTNX:;&lt;BR /&gt;
*** before INTNX:&lt;BR /&gt;
117  %put period1 = &amp;amp;period1;&lt;BR /&gt;
period1 = '1aug2010:0:0'dt&lt;BR /&gt;
118  %put period2 = &amp;amp;period2;&lt;BR /&gt;
period2 = '1jul2010:0:0'dt&lt;BR /&gt;
119  %put period3 = &amp;amp;period3;&lt;BR /&gt;
period3 = '1jun2010:0:0'dt&lt;BR /&gt;
120  %put period4 = &amp;amp;period4;&lt;BR /&gt;
period4 = '1sep2010:0:0'dt&lt;BR /&gt;
121  %put *** *** *** *** ***;&lt;BR /&gt;
*** *** *** *** ***&lt;BR /&gt;
122&lt;BR /&gt;
123&lt;BR /&gt;
124  %let period2 = intnx('month',&amp;amp;period1., -1);&lt;BR /&gt;
125  %put *** after INTNX 1:;&lt;BR /&gt;
*** after INTNX 1:&lt;BR /&gt;
126  %put period2 = &amp;amp;period2;&lt;BR /&gt;
period2 = intnx('month','1aug2010:0:0'dt, -1)&lt;BR /&gt;
127&lt;BR /&gt;
128  %let period2 = intnx('month',&amp;amp;period1, -1);&lt;BR /&gt;
129  %put *** after INTNX 2:;&lt;BR /&gt;
*** after INTNX 2:&lt;BR /&gt;
130  %put period2 = &amp;amp;period2;&lt;BR /&gt;
period2 = intnx('month','1aug2010:0:0'dt, -1)&lt;BR /&gt;
131&lt;BR /&gt;
132  %let period2 = intnx('month','&amp;amp;period1'dt, -1);&lt;BR /&gt;
133  %put *** after INTNX 3:;&lt;BR /&gt;
*** after INTNX 3:&lt;BR /&gt;
134  %put period2 = &amp;amp;period2;&lt;BR /&gt;
period2 = intnx('month','&amp;amp;period1'dt, -1)&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
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 "&amp;amp;bday"d construct in the date function usage -- I don't favor "pre-quoting" macro variable values when the values are assigned:&lt;BR /&gt;
[pre]&lt;BR /&gt;
135  %let bday = 15nov1950;&lt;BR /&gt;
136&lt;BR /&gt;
137  %let mm = %sysfunc(month("&amp;amp;bday"d));&lt;BR /&gt;
138  %let bd = %sysfunc(day("&amp;amp;bday"d));&lt;BR /&gt;
139  %let yr = %sysfunc(year("&amp;amp;bday"d));&lt;BR /&gt;
140&lt;BR /&gt;
141  %put month of bday = &amp;amp;mm;&lt;BR /&gt;
month of bday = 11&lt;BR /&gt;
142  %put day of bday = &amp;amp;bd;&lt;BR /&gt;
day of bday = 15&lt;BR /&gt;
143  %put year of bday = &amp;amp;yr;&lt;BR /&gt;
year of bday = 1950&lt;BR /&gt;
[/pre]&lt;BR /&gt;
             &lt;BR /&gt;
cynthia</description>
    <pubDate>Mon, 18 Oct 2010 18:00:45 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-10-18T18:00:45Z</dc:date>
    <item>
      <title>%let doesn't work with another macro variable??</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-doesn-t-work-with-another-macro-variable/m-p/18493#M3641</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I've created a code in order to create a report, in which I make use of several dates (month ends) which has to be entered at the top of the code (variables with the %let statement). But... to make life easier, I thought it would be a great idea to just enter 1 date, and let SAS compute the other dates.&lt;BR /&gt;
&lt;BR /&gt;
Right now, I've got to enter 4 dates as shown below:&lt;BR /&gt;
&lt;BR /&gt;
%let period1 = '1aug2010:0:0'dt; * the reporting month we're looking at;&lt;BR /&gt;
%let period2 = '1jul2010:0:0'dt; * the month before the reporting month we're looking at;&lt;BR /&gt;
%let period3 = '1jun2010:0:0'dt; * 2 months before reporting month;&lt;BR /&gt;
%let period4 = '1sep2010:0:0'dt; *the month after the reporting month we're looking at;&lt;BR /&gt;
&lt;BR /&gt;
So I tried to create the other dates with the following statement, based on the date given at period1 (in this example, I tried to create period2), with different statements:&lt;BR /&gt;
&lt;BR /&gt;
%let period2 = intnx('month',&amp;amp;period1., -1);&lt;BR /&gt;
%let period2 = intnx('month',&amp;amp;period1, -1);&lt;BR /&gt;
%let period2 = intnx('month','&amp;amp;period1'dt, -1);&lt;BR /&gt;
&lt;BR /&gt;
But... none of these statements are working...&lt;BR /&gt;
&lt;BR /&gt;
After searching a lot, I can't figure out what I'm doing wrong. Can anyone help me with this?&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance!!</description>
      <pubDate>Mon, 18 Oct 2010 17:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-doesn-t-work-with-another-macro-variable/m-p/18493#M3641</guid>
      <dc:creator>Wouter</dc:creator>
      <dc:date>2010-10-18T17:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: %let doesn't work with another macro variable??</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/let-doesn-t-work-with-another-macro-variable/m-p/18494#M3642</link>
      <description>Hi:&lt;BR /&gt;
  %LET is merely assigning TEXT strings to &amp;amp;PERIOD2, as shown in the SAS log below:&lt;BR /&gt;
[pre]&lt;BR /&gt;
111  %let period1 = '1aug2010:0:0'dt; * the reporting month we're&lt;BR /&gt;
111! looking at;&lt;BR /&gt;
112  %let period2 = '1jul2010:0:0'dt; * the month before the&lt;BR /&gt;
112! reporting month we're looking at;&lt;BR /&gt;
113  %let period3 = '1jun2010:0:0'dt; * 2 months before reporting&lt;BR /&gt;
113! month;&lt;BR /&gt;
114  %let period4 = '1sep2010:0:0'dt; *the month after the reporting&lt;BR /&gt;
114! month we're looking at;&lt;BR /&gt;
115&lt;BR /&gt;
116  %put *** before INTNX:;&lt;BR /&gt;
*** before INTNX:&lt;BR /&gt;
117  %put period1 = &amp;amp;period1;&lt;BR /&gt;
period1 = '1aug2010:0:0'dt&lt;BR /&gt;
118  %put period2 = &amp;amp;period2;&lt;BR /&gt;
period2 = '1jul2010:0:0'dt&lt;BR /&gt;
119  %put period3 = &amp;amp;period3;&lt;BR /&gt;
period3 = '1jun2010:0:0'dt&lt;BR /&gt;
120  %put period4 = &amp;amp;period4;&lt;BR /&gt;
period4 = '1sep2010:0:0'dt&lt;BR /&gt;
121  %put *** *** *** *** ***;&lt;BR /&gt;
*** *** *** *** ***&lt;BR /&gt;
122&lt;BR /&gt;
123&lt;BR /&gt;
124  %let period2 = intnx('month',&amp;amp;period1., -1);&lt;BR /&gt;
125  %put *** after INTNX 1:;&lt;BR /&gt;
*** after INTNX 1:&lt;BR /&gt;
126  %put period2 = &amp;amp;period2;&lt;BR /&gt;
period2 = intnx('month','1aug2010:0:0'dt, -1)&lt;BR /&gt;
127&lt;BR /&gt;
128  %let period2 = intnx('month',&amp;amp;period1, -1);&lt;BR /&gt;
129  %put *** after INTNX 2:;&lt;BR /&gt;
*** after INTNX 2:&lt;BR /&gt;
130  %put period2 = &amp;amp;period2;&lt;BR /&gt;
period2 = intnx('month','1aug2010:0:0'dt, -1)&lt;BR /&gt;
131&lt;BR /&gt;
132  %let period2 = intnx('month','&amp;amp;period1'dt, -1);&lt;BR /&gt;
133  %put *** after INTNX 3:;&lt;BR /&gt;
*** after INTNX 3:&lt;BR /&gt;
134  %put period2 = &amp;amp;period2;&lt;BR /&gt;
period2 = intnx('month','&amp;amp;period1'dt, -1)&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
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 "&amp;amp;bday"d construct in the date function usage -- I don't favor "pre-quoting" macro variable values when the values are assigned:&lt;BR /&gt;
[pre]&lt;BR /&gt;
135  %let bday = 15nov1950;&lt;BR /&gt;
136&lt;BR /&gt;
137  %let mm = %sysfunc(month("&amp;amp;bday"d));&lt;BR /&gt;
138  %let bd = %sysfunc(day("&amp;amp;bday"d));&lt;BR /&gt;
139  %let yr = %sysfunc(year("&amp;amp;bday"d));&lt;BR /&gt;
140&lt;BR /&gt;
141  %put month of bday = &amp;amp;mm;&lt;BR /&gt;
month of bday = 11&lt;BR /&gt;
142  %put day of bday = &amp;amp;bd;&lt;BR /&gt;
day of bday = 15&lt;BR /&gt;
143  %put year of bday = &amp;amp;yr;&lt;BR /&gt;
year of bday = 1950&lt;BR /&gt;
[/pre]&lt;BR /&gt;
             &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 18 Oct 2010 18:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/let-doesn-t-work-with-another-macro-variable/m-p/18494#M3642</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-10-18T18:00:45Z</dc:date>
    </item>
  </channel>
</rss>

