<?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 Get each last day of preceding months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-each-last-day-of-preceding-months/m-p/373526#M89367</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to create a dataset called timestamps that lists the last day of each month of the preceding 6 months. My solution for this is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA timestamps;
	d = today();
	format d date9.;
  	DO i=0 TO 5;
  		d = intnx('month',d,-i)-1;
  		output;
  	END;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="dgrid-scroller"&gt;However, I get this as result:&lt;BR /&gt;&lt;IMG title="sas.jpg" alt="sas.jpg" src="https://communities.sas.com/t5/image/serverpage/image-id/10158iA7F44EFC5FA2C065/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;If I "rerun the loop manually", I get the day I expect. E.g. this code&lt;BR /&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA timestamps;
	d = today();
	format d date9.;
  	d = intnx('month',d,-1)-1;
run;&lt;/CODE&gt;&lt;/PRE&gt;gives: 31MAY2017&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;Why do I get 30APR2017 for i =1 in the loop? What is wrong in my loop?&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;Thanks for the help!&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;philip&lt;/DIV&gt;</description>
    <pubDate>Thu, 06 Jul 2017 08:04:28 GMT</pubDate>
    <dc:creator>philip_</dc:creator>
    <dc:date>2017-07-06T08:04:28Z</dc:date>
    <item>
      <title>Get each last day of preceding months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-each-last-day-of-preceding-months/m-p/373526#M89367</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to create a dataset called timestamps that lists the last day of each month of the preceding 6 months. My solution for this is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA timestamps;
	d = today();
	format d date9.;
  	DO i=0 TO 5;
  		d = intnx('month',d,-i)-1;
  		output;
  	END;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="dgrid-scroller"&gt;However, I get this as result:&lt;BR /&gt;&lt;IMG title="sas.jpg" alt="sas.jpg" src="https://communities.sas.com/t5/image/serverpage/image-id/10158iA7F44EFC5FA2C065/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;If I "rerun the loop manually", I get the day I expect. E.g. this code&lt;BR /&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA timestamps;
	d = today();
	format d date9.;
  	d = intnx('month',d,-1)-1;
run;&lt;/CODE&gt;&lt;/PRE&gt;gives: 31MAY2017&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;Why do I get 30APR2017 for i =1 in the loop? What is wrong in my loop?&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;Thanks for the help!&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;philip&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Jul 2017 08:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-each-last-day-of-preceding-months/m-p/373526#M89367</guid>
      <dc:creator>philip_</dc:creator>
      <dc:date>2017-07-06T08:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get each last day of preceding months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-each-last-day-of-preceding-months/m-p/373530#M89369</link>
      <description>&lt;P&gt;At a guess your changing the variable your working on, try:&lt;/P&gt;
&lt;PRE&gt;data timestamps;
  d = today();
  format d dt date9.;
  do i=0 to 5;
    dt=intnx('month',d,-i)-1;
    output;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 08:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-each-last-day-of-preceding-months/m-p/373530#M89369</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-06T08:17:42Z</dc:date>
    </item>
  </channel>
</rss>

