<?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: Iterate (loop) through multiple dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558838#M156002</link>
    <description>&lt;P&gt;hey,&lt;/P&gt;&lt;P&gt;yes, sorry!! thats what i want in output.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 May 2019 09:04:18 GMT</pubDate>
    <dc:creator>ankitasharma</dc:creator>
    <dc:date>2019-05-15T09:04:18Z</dc:date>
    <item>
      <title>Iterate (loop) through multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558814#M155995</link>
      <description>&lt;P&gt;I want to create a new variable "newdate" in my dataset using variable "datex".&amp;nbsp;&lt;/P&gt;&lt;P&gt;if datex is between 01-04-2011 to 31-03-2012 then newdate= 2011-12&amp;nbsp;&lt;/P&gt;&lt;P&gt;loop till 2050.&lt;/P&gt;&lt;P&gt;is there a way in sas I could do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really appreciate your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 06:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558814#M155995</guid>
      <dc:creator>ankitasharma</dc:creator>
      <dc:date>2019-05-15T06:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate (loop) through multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558815#M155996</link>
      <description>&lt;P&gt;Dates are days. Do you want to have all days from 2011-12-01 to 2050-12-31?&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 07:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558815#M155996</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-15T07:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate (loop) through multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558816#M155997</link>
      <description>&lt;P&gt;I think he wants all dates between this period per yer :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;01/04/2011 --&amp;gt; 31/03/2012 = 2011/12&lt;/P&gt;&lt;P&gt;01/04/2012 --&amp;gt; 31/03/2013 = 2012/12&lt;/P&gt;&lt;P&gt;01/04/2013 --&amp;gt; 31/03/2014 = 2013/12&lt;/P&gt;&lt;P&gt;-----&lt;/P&gt;&lt;P&gt;01/04/2050 --&amp;gt; 31/03/2051 = 2050/12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or maybe he wants :&lt;/P&gt;&lt;P&gt;01/04/2011 --&amp;gt; 31/03/2012 = 2011/&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;01/04/2012 --&amp;gt; 31/03/2013 = 2012/&lt;STRONG&gt;13&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;01/04/2013 --&amp;gt; 31/03/2014 = 2013/&lt;STRONG&gt;14&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;-----&lt;/P&gt;&lt;P&gt;01/04/2050 --&amp;gt; 31/03/2051 = 2050/&lt;STRONG&gt;51&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 07:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558816#M155997</guid>
      <dc:creator>Onizuka</dc:creator>
      <dc:date>2019-05-15T07:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate (loop) through multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558835#M156001</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/229511"&gt;@ankitasharma&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The intnx() function allows you to shift SAS date, datetime and time values. Formats allow you to print such values in the form you like.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  format mydate date9.;
  do mydate='31Mar2011'd, '01Apr2011'd, '31Mar2012'd, '01Apr2012'd ;
    output;
  end;
  stop;
run;

data want;
  set have;
  format newdate yymmd7.;
  newdate=intnx('year',intnx('month',mydate,-3,'b'),0,'e');
run;

proc print data=want; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 189px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29533i4756E0F4EAA9E9FD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 08:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558835#M156001</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-15T08:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate (loop) through multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558838#M156002</link>
      <description>&lt;P&gt;hey,&lt;/P&gt;&lt;P&gt;yes, sorry!! thats what i want in output.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 09:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558838#M156002</guid>
      <dc:creator>ankitasharma</dc:creator>
      <dc:date>2019-05-15T09:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate (loop) through multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558842#M156003</link>
      <description>&lt;P&gt;So you want to create a "financial year" from the date. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let startfy=4;

data have;
format datex yymmddd10.;
input datex yymmdd10.;
datalines;
2011-04-01
2011-04-02
2012-03-31
2012-04-01
;

data want;
set have;
length newdate $7;
if month(datex) &amp;gt;= &amp;amp;startfy.
then newdate = catx('/',put(year(datex),z4.),substr(put(year(datex)+1,z4.),3,2));
else newdate = catx('/',put(year(datex)-1,z4.),substr(put(year(datex),z4.),3,2));
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;     datex    newdate

2011-04-01    2011/12
2011-04-02    2011/12
2012-03-31    2011/12
2012-04-01    2012/13
&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 09:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558842#M156003</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-15T09:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate (loop) through multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558867#M156005</link>
      <description>&lt;P&gt;thank you so much for this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 11:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-loop-through-multiple-dates/m-p/558867#M156005</guid>
      <dc:creator>ankitasharma</dc:creator>
      <dc:date>2019-05-15T11:22:14Z</dc:date>
    </item>
  </channel>
</rss>

