<?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: Array looping through dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292460#M60699</link>
    <description>&lt;P&gt;Thx for all suggestions. I used this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;20&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;a = intnx(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'dtmonth'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,datetime(),-i,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'end'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'a'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,put(a,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;datetime32.3&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; a = &amp;amp;a;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;However, the created list contains just one value. It says that macro variable a resolves just the last i's value:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Macro variable A resolves to 31DEC2014:23:59:59.000"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot get how come it does not store all dates?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips? thx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiri&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Aug 2016 14:24:49 GMT</pubDate>
    <dc:creator>Uknown_user</dc:creator>
    <dc:date>2016-08-18T14:24:49Z</dc:date>
    <item>
      <title>Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292385#M60684</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to loop dates so that it returned something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;31jan2015:23:59:59.000&lt;/P&gt;&lt;P&gt;28feb2015:23:59:59.000&lt;/P&gt;&lt;P&gt;31mar2015:23:59:59.000&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;31jul2016:23:59:59.000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code actually does not work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;19&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;a = put(intnx(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'month'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,intnx(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'month'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,today(),-i),&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'end'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; symput (&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'d'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,a||&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;':23:59:59.000'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;d."&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Any suggestions? Thanks&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Jiri&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 09:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292385#M60684</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-08-18T09:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292388#M60686</link>
      <description>&lt;P&gt;Macro calls (everything starting with a &amp;amp; or %) are expanded immediately when encountered in the program text. So SAS tries to find the macro variable d before the data step (that creates a macro variable with call symput during runtime) is compiled and executed.&lt;/P&gt;
&lt;P&gt;Try this for clarification:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do i = 1 to 19;
a = put(intnx('month',intnx('month',today(),-i),0,'end'),date9.);
call symput ('d',a||':23:59:59.000');
end;
run;
%put "d=&amp;amp;d.";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since you seem to want to store a list of dates for later actions, it is better to store them in a dataset and use that later.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 09:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292388#M60686</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-18T09:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292389#M60687</link>
      <description>&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiri&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 09:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292389#M60687</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-08-18T09:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292390#M60688</link>
      <description>&lt;P&gt;And compare my previous post with this (look into the log):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do i = 1 to 19;
a = put(intnx('month',intnx('month',today(),-i),0,'end'),date9.);
d = a||':23:59:59.000';
put d=;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Aug 2016 09:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292390#M60688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-18T09:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292393#M60689</link>
      <description>&lt;P&gt;I tried to run the code with your amendment but it for some reason&amp;nbsp;fails to remember i's values. Any further suggestions? Thanks again&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 09:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292393#M60689</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-08-18T09:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292397#M60690</link>
      <description>&lt;PRE&gt;
data _null_;
do i = 1 to 19;
a = intnx('dtmonth',datetime(),-i,'end');
put a= datetime32.3;
end;
run;

&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Aug 2016 10:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292397#M60690</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-18T10:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292399#M60691</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/95386"&gt;@Uknown_user&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I tried to run the code with your amendment but it for some reason&amp;nbsp;fails to remember i's values. Any further suggestions? Thanks again&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This very much depends on what you want to do with your list of dates and index numbers.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 10:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292399#M60691</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-18T10:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292460#M60699</link>
      <description>&lt;P&gt;Thx for all suggestions. I used this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;20&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;a = intnx(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'dtmonth'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,datetime(),-i,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'end'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'a'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,put(a,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;datetime32.3&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; a = &amp;amp;a;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;However, the created list contains just one value. It says that macro variable a resolves just the last i's value:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Macro variable A resolves to 31DEC2014:23:59:59.000"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot get how come it does not store all dates?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips? thx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiri&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 14:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292460#M60699</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-08-18T14:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292465#M60703</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The call symput named every value with the same macro variable name. Also, you only requested to see one value. You would have to assign multi macro variable names and then a different %put (or other approach) to see them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   length aname $ 10;
   do i = 2 to 20;
      aname = cats('a',i);
      a = intnx('dtmonth',datetime(),-i,'end');
      call symput(aname,put(a,datetime32.3));
   end;
run;
%put &amp;amp;a2 &amp;amp;a3 &amp;amp;a4 &amp;amp;a20;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Aug 2016 14:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292465#M60703</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-18T14:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292470#M60706</link>
      <description>&lt;P&gt;Thx, is there any way to store all values from the created list of dates&amp;nbsp;and work with them as with single&amp;nbsp;object (one macro variable)? Writing down all values might be complicated when the range gets bigger. When I put object "aname" from your code into macro variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a = &amp;amp;aname;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;It says:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"WARNING: Apparent symbolic reference ANAME not resolved."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not quite sure how to work with arrays but it could help this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiri&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 15:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292470#M60706</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-08-18T15:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292477#M60711</link>
      <description>&lt;P&gt;%put &amp;amp;aname fails because you did not create a MACRO varaible aname. You would have had to have a call symput("aname", ) for that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing your exact useage it is a bit difficult to say what to put in the list. For instance if you want to use the values later such as this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if somevariable in (&amp;lt;macro list&amp;gt;) then do ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the values of the elements of the macro list probably should &lt;STRONG&gt;not&lt;/STRONG&gt; be formatted datetimes as then you have to add quotes and DT to indicate they are date literals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one way to build a list that is comma separated, remove the comma from the "separated by&amp;nbsp;', ' " if you want spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
   length aname $ 10;
   do i = 2 to 20;
      a = intnx('dtmonth',datetime(),-i,'end');
      output;
   end;
run;

proc sql noprint;
   select put(a,datetime32.3)  into : a separated by ', '
   from temp
   ;
quit;

%put &amp;amp;a;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the addition of creating a dataset and the output statment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This approach may be the easiest overall for a single list because it does not requie pre-calculating the length of the character value that would be needed in the data step approach. There is a default maximum size for the length of a single macro variable do consider. If you are generating enough of these to approach the 65,000 characters your approach should be reconsidered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you describe what you are actually going to do with this list it would help as I suspect you are going to cause yourself more work than needed.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 15:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292477#M60711</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-18T15:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292659#M60796</link>
      <description>&lt;P&gt;Thanks for your reply. I am trying to produce the list of dates:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;30JUN2016:23:59:59.000&lt;/P&gt;&lt;P&gt;31MAY2016:23:59:59.000&lt;/P&gt;&lt;P&gt;30APR2016:23:59:59.000&lt;/P&gt;&lt;P&gt;31MAR2016:23:59:59.000&lt;/P&gt;&lt;P&gt;29FEB2016:23:59:59.000&lt;/P&gt;&lt;P&gt;31JAN2016:23:59:59.000&lt;/P&gt;&lt;P&gt;31DEC2015:23:59:59.000&lt;/P&gt;&lt;P&gt;30NOV2015:23:59:59.000&lt;/P&gt;&lt;P&gt;31OCT2015:23:59:59.000&lt;/P&gt;&lt;P&gt;30SEP2015:23:59:59.000&lt;/P&gt;&lt;P&gt;31AUG2015:23:59:59.000&lt;/P&gt;&lt;P&gt;31JUL2015:23:59:59.000&lt;/P&gt;&lt;P&gt;30JUN2015:23:59:59.000&lt;/P&gt;&lt;P&gt;31MAY2015:23:59:59.000&lt;/P&gt;&lt;P&gt;30APR2015:23:59:59.000&lt;/P&gt;&lt;P&gt;31MAR2015:23:59:59.000&lt;/P&gt;&lt;P&gt;28FEB2015:23:59:59.000&lt;/P&gt;&lt;P&gt;31JAN2015:23:59:59.000&lt;/P&gt;&lt;P&gt;31DEC2014:23:59:59.000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which will consequently source the macro (each date should be one macro variable, so in the first step it goes for ... then ..., etc)&amp;nbsp;. The format of datetime is required by the macro it self. Any suggestions how to aporoach this? Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 06:54:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292659#M60796</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-08-19T06:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292660#M60797</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let num_months=19;

data temp;
length datetime_value $ 10;
do i = 0 to &amp;amp;num_months - 1;
  datetime_value = intnx('dtmonth',datetime(),i,'end');
  output;
end;
run;

data _null_;
set temp;
call execute('%your_macro('!!put(datetime_value,best.)!!')');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You only have to set the number of months, everything else happens dynamically, and the code is rather simple.&lt;/P&gt;
&lt;P&gt;Anytime you need to work through a list of values, consider storing them in a dataset and working from that.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 07:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292660#M60797</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-19T07:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Array looping through dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292661#M60798</link>
      <description>&lt;P&gt;Thanks for help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jiri&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 07:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-looping-through-dates/m-p/292661#M60798</guid>
      <dc:creator>Uknown_user</dc:creator>
      <dc:date>2016-08-19T07:08:41Z</dc:date>
    </item>
  </channel>
</rss>

