<?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: Finding the last day of a month excluding Sundays in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-last-day-of-a-month-excluding-Sundays/m-p/525352#M4948</link>
    <description>Thanks for this, it's not exactly what I was after but has shown me a couple of new things I haven't seen before which is always good.</description>
    <pubDate>Tue, 08 Jan 2019 08:40:20 GMT</pubDate>
    <dc:creator>robulon</dc:creator>
    <dc:date>2019-01-08T08:40:20Z</dc:date>
    <item>
      <title>Finding the last day of a month excluding Sundays</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-last-day-of-a-month-excluding-Sundays/m-p/524994#M4885</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a bit frustrated with myself at not being able to figure this out but there you. Where I work creates daily batch files except for on a Sunday. I want to be able to identify the last created batch file for a month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could (and indeed have been) using: -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;if weekday(intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="1"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;,current_month, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;) - &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;) ne &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt; then mthend = intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="1"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;,current_month, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;) -&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;else mthend = intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="1"&gt;'month'&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;,current_month, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;) -&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="1"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But was hoping for something a bit more aesthetically pleasing. I thought I could use a variation on&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: Consolas; font-size: 9pt;"&gt;last_month_busday = intnx(&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: Consolas; font-size: 9pt;"&gt;'WEEKDAY'&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: Consolas; font-size: 9pt;"&gt;, intnx(&lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: Consolas; font-size: 9pt;"&gt;'MONTH'&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: Consolas; font-size: 9pt;"&gt;, date, -&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: Consolas; font-size: 9pt;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="background: white; color: purple; font-family: Consolas; font-size: 9pt;"&gt;'END'&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: Consolas; font-size: 9pt;"&gt;), &lt;/SPAN&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: Consolas; font-size: 9pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but replacing 'WEEKDAY' with 'WEEKDAY234567w' which I thought would omit Sundays from consideration but this is not working. If anyone could suggest a way to do this, I would really appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: Consolas; font-size: 9pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 09:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-last-day-of-a-month-excluding-Sundays/m-p/524994#M4885</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-07T09:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the last day of a month excluding Sundays</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-last-day-of-a-month-excluding-Sundays/m-p/525024#M4886</link>
      <description>&lt;P&gt;Not pretty, but this is a single statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  current_date=mdy(3,7,2019);
  last_bus_day=intnx('month',current_date,0,'E') - (weekday(intnx('month',current_date,0,'E'))=1);
  put (_all_) (=weekdate20.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It&amp;nbsp; might make sense for other users&amp;nbsp; of the program to see two lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  current_date=mdy(3,7,2019);
  last_bus_day=intnx('month',current_date,0,'E');
  if weekday(intnx('month',current_date,0,'E'))=1 then last_bus_day=last_bus_day-1;
  put (_all_) (=weekdate20.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Editted note:&lt;/P&gt;
&lt;P&gt;In the second block of code, I should have put:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if weekday(last_bus_day)=1 then last_bus_day=last_bus_day-1;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;instead of the long IF statement I entered.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 08:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-last-day-of-a-month-excluding-Sundays/m-p/525024#M4886</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-01-08T08:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the last day of a month excluding Sundays</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-last-day-of-a-month-excluding-Sundays/m-p/525352#M4948</link>
      <description>Thanks for this, it's not exactly what I was after but has shown me a couple of new things I haven't seen before which is always good.</description>
      <pubDate>Tue, 08 Jan 2019 08:40:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-last-day-of-a-month-excluding-Sundays/m-p/525352#M4948</guid>
      <dc:creator>robulon</dc:creator>
      <dc:date>2019-01-08T08:40:20Z</dc:date>
    </item>
  </channel>
</rss>

