<?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: Using INTCK function in the loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-INTCK-function-in-the-loop/m-p/169950#M32666</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks for your quick response!&lt;/P&gt;&lt;P&gt;It worked perfectly and yes, I will review the SAS documentation once again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hatsumi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 May 2014 20:42:45 GMT</pubDate>
    <dc:creator>hatsumi</dc:creator>
    <dc:date>2014-05-22T20:42:45Z</dc:date>
    <item>
      <title>Using INTCK function in the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-INTCK-function-in-the-loop/m-p/169948#M32664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wrote below macro and it works fine as long as I have the counter n as a hard-coded number like 20.&lt;/P&gt;&lt;P&gt;but I would like this macro to be more flexible and I want to insert INTCK function to automatically count the number of iterations from last month to the end of next year.&lt;/P&gt;&lt;P&gt;So in the 2nd macro, I inserted the INTCK function following the examples in this forum but it produces an error.&lt;/P&gt;&lt;P&gt;My data is monthly and INTCK function works fine itself but not within a loop.&lt;/P&gt;&lt;P&gt;I appreciate if anyone could point out how to fix this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;ORIGINAL&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;lag&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; n=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%to&lt;/SPAN&gt; &lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;20&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; data data_horizon&amp;amp;n;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; set data_horizon0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; A_L=lag&amp;amp;n(A);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; &lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;lag&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;FLEXIBLE&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;lag&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt; n=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%to&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;%sysfunc(intck('month', mdy(month(today())-1,01,year(today())), mdy(12,01,year(today())+1)))&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; data data_horizon&amp;amp;n;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; set data_horizon0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; A_L=lag&amp;amp;n(A);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; &lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;lag&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 20:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-INTCK-function-in-the-loop/m-p/169948#M32664</guid>
      <dc:creator>hatsumi</dc:creator>
      <dc:date>2014-05-22T20:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTCK function in the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-INTCK-function-in-the-loop/m-p/169949#M32665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think you put quotes around month inside of %sysfunc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You probably also need to nest %sysfunc calls, as explained in the SAS documentation, which means it probably would be easier to do something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx('niter',intck('month', mdy(month(today())-1,01,year(today())), mdy(12,01,year(today())+1))))&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do n=1 %to &amp;amp;niter;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 20:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-INTCK-function-in-the-loop/m-p/169949#M32665</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2014-05-22T20:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using INTCK function in the loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-INTCK-function-in-the-loop/m-p/169950#M32666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks for your quick response!&lt;/P&gt;&lt;P&gt;It worked perfectly and yes, I will review the SAS documentation once again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hatsumi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 20:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-INTCK-function-in-the-loop/m-p/169950#M32666</guid>
      <dc:creator>hatsumi</dc:creator>
      <dc:date>2014-05-22T20:42:45Z</dc:date>
    </item>
  </channel>
</rss>

