<?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 Function to check for a business day in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10405#M785</link>
    <description>Is there a function in SAS that I can use to check if a given date is a business day and if its not a business day, then find the previous or the next business day?</description>
    <pubDate>Mon, 26 Apr 2010 20:08:50 GMT</pubDate>
    <dc:creator>model_coder</dc:creator>
    <dc:date>2010-04-26T20:08:50Z</dc:date>
    <item>
      <title>Function to check for a business day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10405#M785</link>
      <description>Is there a function in SAS that I can use to check if a given date is a business day and if its not a business day, then find the previous or the next business day?</description>
      <pubDate>Mon, 26 Apr 2010 20:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10405#M785</guid>
      <dc:creator>model_coder</dc:creator>
      <dc:date>2010-04-26T20:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Function to check for a business day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10406#M786</link>
      <description>Hi:&lt;BR /&gt;
  In the simplest form, the WEEKDAY function can take a SAS date value as an argument and return the day of the week, as a number (1=Sunday, 2=Monday, etc, 7=Saturday). Using that returned value as a starting point, you can write logic to advance the date until the weekday function returns a value between 2-6 (Monday-Friday).&lt;BR /&gt;
&lt;BR /&gt;
  If by "business day" you mean something more sophisticated (such as taking holidays into account) and finding the next date, then you might need to use logic such as found in this Tech Support note:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/26/044.html" target="_blank"&gt;http://support.sas.com/kb/26/044.html&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 26 Apr 2010 20:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10406#M786</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-26T20:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Function to check for a business day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10407#M787</link>
      <description>Thanks Cynthia. I already implemented a code that somewhat matches your suggestion. But then I ran into the issue of holidays. I guess we need to implement something more sophisticated as suggested in your tech note.&lt;BR /&gt;
Thanks for help!</description>
      <pubDate>Mon, 26 Apr 2010 20:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10407#M787</guid>
      <dc:creator>model_coder</dc:creator>
      <dc:date>2010-04-26T20:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Function to check for a business day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10408#M788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To find the next business day , use INTNX('WEEKDAY',...)&amp;nbsp; - see code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp; if Thisdate = intnx('WEEKDAY',Thisdate,0) then NextWorkday=Thisdate; else NextWorkday=intnx('weekday',Thisdate,1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To find the previous business day, simply use &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PreviousBusinessday = intnx('weekday',Thisdate,0) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This does not take into account holidays, only Saturday &amp;amp; Sunday.&lt;/P&gt;&lt;P&gt;In Saudi Arabia, where weekend is on Thursday &amp;amp; Friday, use this code instead &lt;/P&gt;&lt;P&gt;intnx('weekday56w',Thisdate,0) ;&amp;nbsp; see &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003065889.htm#a003065892" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003065889.htm#a003065892"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 11:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10408#M788</guid>
      <dc:creator>JLD</dc:creator>
      <dc:date>2013-03-28T11:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Function to check for a business day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10409#M789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, SAS does have a holiday function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Generating_Holiday_Lists" title="http://www.sascommunity.org/wiki/Generating_Holiday_Lists"&gt;http://www.sascommunity.org/wiki/Generating_Holiday_Lists&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ron Fehd sas.comm.wiki maven&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 15:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10409#M789</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2013-03-28T15:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Function to check for a business day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10410#M790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And, if you need to expand the holiday function to incorporate holidays that aren't already included in the holiday function, take a look at the customizable holiday function at: &lt;A href="http://www.sascommunity.org/wiki/Sometimes_One_Needs_an_Option_with_Unusual_Dates" title="http://www.sascommunity.org/wiki/Sometimes_One_Needs_an_Option_with_Unusual_Dates"&gt;http://www.sascommunity.org/wiki/Sometimes_One_Needs_an_Option_with_Unusual_Dates&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2013 15:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/10410#M790</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-03-28T15:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Function to check for a business day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/474750#M122021</link>
      <description>&lt;P&gt;proc fcmp outlib = work.funcs.dt;&lt;BR /&gt;/*use the function compiler procedure*/&lt;/P&gt;&lt;P&gt;function nextworkday(startday, interval);/*define a custom function*/&lt;BR /&gt;x= intnx("weekday1w",startday,interval);/*interval is the number of days after which you want to check for a business day*/&lt;/P&gt;&lt;P&gt;if x not in &amp;amp;holidays then&lt;BR /&gt;return(x);&lt;BR /&gt;else return(nextworkday(x,interval-(interval-1)));/*use recursion to check if day next day after interval falls on a holiday*/&lt;BR /&gt;endsub;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;options cmplib=work.dt;&lt;BR /&gt;%let holidays=("01JAN2018"d, "16FEB2018"D, "17FEB2018"D, "30MAR2018"D, "01MAY2018"D, "29MAY2018"D, "15JUN2018"D, "09AUG2018"D, "22AUG2018"D, "06NOV2018"D, "25DEC2018"D);/*These are singapore holidays for FY '18*/&lt;BR /&gt;%let startdate="01jan2018"d;&lt;BR /&gt;%let enddate="31dec2018"d;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;do i= intnx("month",&amp;amp;startdate,0,"b") to intnx("month",&amp;amp;enddate,0,"e");&lt;BR /&gt;j=put(i,date9.);&lt;BR /&gt;z=nextworkday(i,3);&lt;BR /&gt;format z date9.;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jul 2018 11:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Function-to-check-for-a-business-day/m-p/474750#M122021</guid>
      <dc:creator>prasadborra</dc:creator>
      <dc:date>2018-07-01T11:54:24Z</dc:date>
    </item>
  </channel>
</rss>

