<?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: How to find the last date of a month. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71527#M20651</link>
    <description>&lt;P&gt;Editor's Note:&amp;nbsp; Thanks to sreeram for showing the optional fourth argument to the INTNX function that allows you to specify the alignment when incrementing the date.&amp;nbsp; To find the last day of the month, the alignment should be set to 'END' or 'E'.&amp;nbsp; This will increment the starting date so that it falls on the last day of the month.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of concatenating the '01' to the starting value, the ANYDTDTE informat can be used to create a SAS date from just the year and month.&amp;nbsp; The resulting SAS date will default to the first day of the month.&amp;nbsp; This slight modification has been made to sreeram's original code.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;     
aeendtc1='2007-09';
aeendtc2=input(aeendtc1,anydtdte7.);
lastDay=intnx ('month',aeendtc2,0,'E');
mydate=put(lastday,yymmdd10.);
run;
proc print;
  format aeendtc2 lastday yymmddd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt; aeendtc1=strip(aeendtc)||"-01";&lt;BR /&gt; aeendtc2=input(aeendtc1,yymmdd10.);&lt;BR /&gt; lastDay=intnx ('month',aeendtc2,0,'E');&lt;BR /&gt; mydate=put(lastday,yymmdd10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2016 21:04:01 GMT</pubDate>
    <dc:creator>sreeram</dc:creator>
    <dc:date>2016-11-09T21:04:01Z</dc:date>
    <item>
      <title>How to find the last date of a month.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71526#M20650</link>
      <description>i have a CHARACTER VARIABLE in which dates are partially written, ie. '2007-09', '2010-10' etc. Now i have to find the last date of the month ie. in 2007-09, last date in the month 09 added to the new variable representing like 2007-09-30 etc. Can some one help me in doing this.

Message was edited by: sreeram</description>
      <pubDate>Tue, 31 May 2011 19:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71526#M20650</guid>
      <dc:creator>sreeram</dc:creator>
      <dc:date>2011-05-31T19:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the last date of a month.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71527#M20651</link>
      <description>&lt;P&gt;Editor's Note:&amp;nbsp; Thanks to sreeram for showing the optional fourth argument to the INTNX function that allows you to specify the alignment when incrementing the date.&amp;nbsp; To find the last day of the month, the alignment should be set to 'END' or 'E'.&amp;nbsp; This will increment the starting date so that it falls on the last day of the month.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of concatenating the '01' to the starting value, the ANYDTDTE informat can be used to create a SAS date from just the year and month.&amp;nbsp; The resulting SAS date will default to the first day of the month.&amp;nbsp; This slight modification has been made to sreeram's original code.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;     
aeendtc1='2007-09';
aeendtc2=input(aeendtc1,anydtdte7.);
lastDay=intnx ('month',aeendtc2,0,'E');
mydate=put(lastday,yymmdd10.);
run;
proc print;
  format aeendtc2 lastday yymmddd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt; aeendtc1=strip(aeendtc)||"-01";&lt;BR /&gt; aeendtc2=input(aeendtc1,yymmdd10.);&lt;BR /&gt; lastDay=intnx ('month',aeendtc2,0,'E');&lt;BR /&gt; mydate=put(lastday,yymmdd10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 21:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71527#M20651</guid>
      <dc:creator>sreeram</dc:creator>
      <dc:date>2016-11-09T21:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the last date of a month.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71528#M20652</link>
      <description>Hello Sreeram,&lt;BR /&gt;
[pre]&lt;BR /&gt;
This is a solution:&lt;BR /&gt;
data i;&lt;BR /&gt;
  input dt0 $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
2007-09&lt;BR /&gt;
2007-10&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  dt=INPUT(CATS(dt0,"-01"),ANYDTDTE10.);&lt;BR /&gt;
  dr=INTNX("MONTH",dt,1,"BEGINNING")-1;&lt;BR /&gt;
  format dt date7. dr YYMMDD10.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 31 May 2011 20:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71528#M20652</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-05-31T20:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the last date of a month.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71529#M20653</link>
      <description>&amp;gt; i have a CHARACTER VARIABLE in which dates are&lt;BR /&gt;
&amp;gt; partially written, ie. '2007-09', '2010-10' etc. Now&lt;BR /&gt;
&amp;gt; i have to find the last date of the month ie. in&lt;BR /&gt;
&amp;gt; 2007-09, last date in the month 09 added to the new&lt;BR /&gt;
&amp;gt; variable representing like 2007-09-30 etc. Can some&lt;BR /&gt;
&amp;gt; one help me in doing this.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&lt;BR /&gt;
intnx( 'month', input( cats(your_char_var, '-01'), yymmdd10.), 0, 'ending' )</description>
      <pubDate>Tue, 31 May 2011 22:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-last-date-of-a-month/m-p/71529#M20653</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-05-31T22:19:55Z</dc:date>
    </item>
  </channel>
</rss>

