<?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 intnx looping in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553156#M153793</link>
    <description>&lt;P&gt;When i run the program, period_1 appear in the date1 dataset, may i know how to output period_2 to period_24 into the date1 dataset? Thanks.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data date1;&lt;BR /&gt;date1 = intnx('month',&amp;amp;today,-1,'end');&lt;BR /&gt;period_1 = substr(put(date1, yymmddn8.),3,4);&lt;BR /&gt;do i=2 to 24;&lt;BR /&gt;call symput(cats("Period_",i),substr(put(intnx('month',date1,-(i-1),'end'),yymmddn8.),3,4));&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2019 09:58:14 GMT</pubDate>
    <dc:creator>scb</dc:creator>
    <dc:date>2019-04-23T09:58:14Z</dc:date>
    <item>
      <title>intnx looping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553156#M153793</link>
      <description>&lt;P&gt;When i run the program, period_1 appear in the date1 dataset, may i know how to output period_2 to period_24 into the date1 dataset? Thanks.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data date1;&lt;BR /&gt;date1 = intnx('month',&amp;amp;today,-1,'end');&lt;BR /&gt;period_1 = substr(put(date1, yymmddn8.),3,4);&lt;BR /&gt;do i=2 to 24;&lt;BR /&gt;call symput(cats("Period_",i),substr(put(intnx('month',date1,-(i-1),'end'),yymmddn8.),3,4));&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 09:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553156#M153793</guid>
      <dc:creator>scb</dc:creator>
      <dc:date>2019-04-23T09:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: intnx looping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553172#M153798</link>
      <description>&lt;P&gt;Use arrays:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today=today();
data date1;
  array period_[24] $ 10;
  do i=1 to 24;
    date1 = intnx('month',&amp;amp;today,-i,'end');
    period_[i] = substr(put(date1, yymmddn8.),3,4);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 11:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553172#M153798</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-04-23T11:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: intnx looping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553191#M153801</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80526"&gt;@scb&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;When i run the program, period_1 appear in the date1 dataset, may i know how to output period_2 to period_24 into the date1 dataset? Thanks.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data date1;&lt;BR /&gt;date1 = intnx('month',&amp;amp;today,-1,'end');&lt;BR /&gt;period_1 = substr(put(date1, yymmddn8.),3,4);&lt;BR /&gt;do i=2 to 24;&lt;BR /&gt;call symput(cats("Period_",i),substr(put(intnx('month',date1,-(i-1),'end'),yymmddn8.),3,4));&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;May I recommend that you avoid macro variables and CALL SYMPUT when data step functions will do the job?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I also recommend that you not store calendar information as characters strings like '1903'? Instead, they should be stored as actual numeric SAS date values and formatted as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data date1;
    array period_(24);
    today=today();
    do i=1 to 24;
         period(i) = intnx('month',today,-i,'e');
    end;
    format period_: yymmn4.;   
    drop i today;
run;
        &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 12:45:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553191#M153801</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-23T12:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: intnx looping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553253#M153827</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/80526"&gt;@scb&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's always a bit difficult to really provide an answer just based on code posted but without any sample data (like Have and Want).&lt;/P&gt;
&lt;P&gt;Based on your code: Macro level code is great for dynamic code but it's really not the appropriate design to just hold data. Even if things work as desired it will lead to a lot of complicated and unnecessary macro coding.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 13:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/intnx-looping/m-p/553253#M153827</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-04-23T13:44:49Z</dc:date>
    </item>
  </channel>
</rss>

