<?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: macro to exclude week end days and company holidays from the count of days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356144#M83480</link>
    <description>&lt;P&gt;I would recommend building a custom time interval instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you don't have SAS/ETS this is still valid for INTNX(). See the latter example which uses INTCK (not INTNX).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_intervals_sect008.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_intervals_sect008.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2017 21:49:43 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-05-04T21:49:43Z</dc:date>
    <item>
      <title>macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356141#M83478</link>
      <description>&lt;P&gt;good day,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to calculate&amp;nbsp;number of work days&amp;nbsp;between 2 given dates (start and the end). I need to do a couple&amp;nbsp;things&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) I want to exclude weekends (sat and sunday) from my count&lt;/P&gt;
&lt;P&gt;2) and I want to exclude company holidays (6 days) from my count&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as an example, if the &lt;STRONG&gt;start-date&lt;/STRONG&gt; is May 1 2017 and the &lt;STRONG&gt;end-date&lt;/STRONG&gt; is may may 19 2017. Assuming that May 4 and May 5 are company holidays, then I want the macro to return a count of 13... here is how it should count&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;M &amp;nbsp; &amp;nbsp;T &amp;nbsp; W &amp;nbsp; &amp;nbsp;T &amp;nbsp; &amp;nbsp; F &amp;nbsp; S &amp;nbsp; S&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &lt;STRIKE&gt;4 &amp;nbsp; &amp;nbsp;5&lt;/STRIKE&gt; &amp;nbsp; &amp;nbsp;&lt;STRIKE&gt;6 &amp;nbsp; 7&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;8 &amp;nbsp; &amp;nbsp; 9 &amp;nbsp; 10 &amp;nbsp; 11 &amp;nbsp;12 &amp;nbsp;&lt;STRIKE&gt;13 14&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;15 &amp;nbsp;16 &amp;nbsp;17 &amp;nbsp; 18 &amp;nbsp;19&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 21:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356141#M83478</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-04T21:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356144#M83480</link>
      <description>&lt;P&gt;I would recommend building a custom time interval instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you don't have SAS/ETS this is still valid for INTNX(). See the latter example which uses INTCK (not INTNX).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_intervals_sect008.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_intervals_sect008.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 21:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356144#M83480</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-04T21:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356146#M83482</link>
      <description>&lt;P&gt;If your company holidays are always on weekdays, then you could get away with something as simple as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  count=intck('weekdays','01may2017'd,'19may2017'd)-1;
  put count;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 21:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356146#M83482</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-04T21:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356161#M83489</link>
      <description>check out this paper on making a report of activity by weeks&lt;BR /&gt;&lt;BR /&gt;Pretty Dates All in a Row&lt;BR /&gt;&lt;BR /&gt;Dianne Rhodes&lt;BR /&gt;&lt;BR /&gt;www2.sas.com/proceedings/sugi31/015-31.pdf&lt;BR /&gt;</description>
      <pubDate>Thu, 04 May 2017 22:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/356161#M83489</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2017-05-04T22:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357316#M83863</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried a few things and nothing worked so far. here is what I am trying to do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;current query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select (date_end-date_start) as Calender_days&lt;/P&gt;
&lt;P&gt;from&lt;/P&gt;
&lt;P&gt;Table_A;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this query return calander days between start and the end date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the same query to now return only the work days minus Holidays (selected ones)... here is the script that I found to identify the holidays but I am unable to figure out the logic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data holidays ;&lt;BR /&gt;length HolidayName $ 30 ;&lt;BR /&gt;array WkDayShift [7] _temporary_ ( 1 5*0 -1 ) ;&lt;BR /&gt;retain ShiftToggle /* 0 */ 1 ;&lt;BR /&gt;do Year = 1971 to 2070 ;&lt;BR /&gt; &lt;BR /&gt; HolidayName = "New Year's Day" ;&lt;BR /&gt; * 1 Jan if not Mon 2 Jan. ;&lt;BR /&gt; HoliDate = holiday('newyear', year) ;&lt;BR /&gt; dow = weekday(HoliDate) ;&lt;BR /&gt; HoliDate = intnx( 'day', HoliDate, WkDayShift[dow] * ShiftToggle ) ;&lt;BR /&gt; if not ( (dow EQ 7) and ShiftToggle ) then output ;&lt;BR /&gt; &lt;BR /&gt; HolidayName = "Martin Luther King Day" ;&lt;BR /&gt; * 3rd Mon in Jan ;&lt;BR /&gt; HoliDate = holiday('mlk', year) ;&lt;BR /&gt; output ; &lt;BR /&gt; &lt;BR /&gt; HolidayName = "Presidents' Day" ;&lt;BR /&gt; * 3rd Mon in Feb ;&lt;BR /&gt; HoliDate = holiday('uspresidents', year) ;&lt;BR /&gt; output ; &lt;BR /&gt; &lt;BR /&gt; HolidayName = "Memorial Day" ;&lt;BR /&gt; * Last Mon in May ;&lt;BR /&gt; HoliDate = holiday('memorial', year) ;&lt;BR /&gt; output ;&lt;BR /&gt; &lt;BR /&gt; HolidayName = "Independence Day" ;&lt;BR /&gt; * 4 Jul if not Mon 5 Jul or Fri 3 Jul ;&lt;BR /&gt; HoliDate = holiday('usindependence',year) ;&lt;BR /&gt; HoliDate = intnx('day',&lt;BR /&gt; HoliDate,&lt;BR /&gt; WkDayShift[ weekday(HoliDate) ] * ShiftToggle) ;&lt;BR /&gt; output ; &lt;BR /&gt; &lt;BR /&gt; HolidayName = "Labor Day" ;&lt;BR /&gt; * 1st Mon in Sep ;&lt;BR /&gt; HoliDate = holiday('labor', year) ;&lt;BR /&gt; output ;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; HolidayName = "Thanksgiving Day" ;&lt;BR /&gt; *4th Thu in Nov ;&lt;BR /&gt; HoliDate = holiday('thanksgiving', year) ;&lt;BR /&gt; output ;&lt;BR /&gt; &lt;BR /&gt; HolidayName = "Christmas" ;&lt;BR /&gt; * 25 Dec if not Mon 26 Dec or Fri 24 Dec ;&lt;BR /&gt; HoliDate = holiday('christmas', year) ; &lt;BR /&gt; HoliDate = intnx('day',&lt;BR /&gt; HoliDate,&lt;BR /&gt; WkDayShift[ weekday(HoliDate) ] * ShiftToggle) ;&lt;BR /&gt; output ;&lt;BR /&gt; &lt;BR /&gt; HolidayName = "New Year's Eve" ;&lt;BR /&gt; * Fri 31 Dec or not at all ;&lt;BR /&gt; HoliDate = mdy(12, 31, year) ;&lt;BR /&gt; if weekday(HoliDate) EQ 6 and ShiftToggle then output ;&lt;BR /&gt; &lt;BR /&gt; end ;&lt;BR /&gt; &lt;BR /&gt;keep year HolidayName HoliDate ;&lt;BR /&gt;format HoliDate weekdate17. ;&lt;BR /&gt;run ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=holidays ;&lt;BR /&gt;where year in (2017, 2018) ;&lt;BR /&gt;by year ;&lt;BR /&gt;id year ;&lt;BR /&gt;run ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&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;&amp;nbsp;&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;</description>
      <pubDate>Tue, 09 May 2017 21:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357316#M83863</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-09T21:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357318#M83864</link>
      <description>&lt;P&gt;Are you in the US? Which Holidays are you factoring in?&lt;/P&gt;
&lt;P&gt;Please FORMAT YOUR CODE. Trying to read unformatted code is likely trying to read a sentence without any punctuation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 21:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357318#M83864</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-09T21:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357327#M83869</link>
      <description>&lt;P&gt;yes, I am in US and want to factor in following hollidys&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Memorial Day&lt;/LI&gt;
&lt;LI&gt;Independence Day&lt;/LI&gt;
&lt;LI&gt;Labor Day&lt;/LI&gt;
&lt;LI&gt;Thanksgiving Day&lt;/LI&gt;
&lt;LI&gt;Christmas&amp;nbsp; Day&lt;/LI&gt;
&lt;LI&gt;New Year's Day&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 22:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357327#M83869</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-09T22:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357335#M83870</link>
      <description>&lt;P&gt;You created the holidays dataset but it doesn't show you trying to use it anywhere. Am I missing something here?&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 23:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357335#M83870</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-09T23:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357347#M83873</link>
      <description>&lt;P&gt;here is the code that I've used&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let date = feb2017;&lt;BR /&gt;%let date1 = '01feb2017'd;&lt;BR /&gt;%let date2 = '01mar2017'd;&lt;BR /&gt;&lt;BR /&gt;options intervalds=(WorkDays=WorkDayDS);&lt;/P&gt;
&lt;P&gt;data WorkDayDS(keep=BEGIN);&lt;BR /&gt; start = '15DEC1998'D;&lt;BR /&gt; stop = '15JAN2030'D;&lt;BR /&gt; nwkdays = INTCK('WEEKDAY',start_Date,End_date);&lt;BR /&gt; do i = 0 to nwkdays;&lt;BR /&gt; BEGIN = INTNX('WEEKDAY',start_Date,i);&lt;BR /&gt; year = YEAR(BEGIN);&lt;BR /&gt; if BEGIN ne HOLIDAY("NEWYEAR",year) and &lt;BR /&gt; BEGIN ne HOLIDAY("MEMORIAL",year) and &lt;BR /&gt; BEGIN ne HOLIDAY("USINDEPENDENCE",year) and &lt;BR /&gt; BEGIN ne HOLIDAY("LABOR",year) and &lt;BR /&gt; BEGIN ne HOLIDAY("THANKSGIVING",year) and &lt;BR /&gt; BEGIN ne HOLIDAY("CHRISTMAS",year) then&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; format BEGIN DATE.;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;proc sql;&lt;BR /&gt;create table temp2&lt;BR /&gt;as&lt;BR /&gt;select *,&lt;BR /&gt;INTCK('WorkDays',Start_Date,End_date)/(60*60*24) as workdays&lt;BR /&gt;from DB.v_all_2017 &lt;BR /&gt;where &amp;amp;date1 &amp;lt;= sched_dt &amp;lt; &amp;amp;date2;&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;&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;/P&gt;
&lt;P&gt;Issue 1: the output has 0 values for all the columns&lt;/P&gt;
&lt;P&gt;Issue 2: if the holiday is on the weekend, then it's not switching... my other code that I've posted previously was switching the days perfectly but I don't know how to use it in the code above&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 00:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357347#M83873</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-10T00:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357366#M83877</link>
      <description>&lt;P&gt;Try the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data wrkdays (keep=begin);
  format begin date9.;
  array holidays(6);
  do date = '01jan1971'd to '31dec2070'd ;
    if date eq intnx('year',date,0,'b') then do;
      call missing(of holidays(*));
      i=0;
    end;
    if date eq holiday('NEWYEAR', year(date)) or
       date eq holiday('USINDEPENDENCE',year(date)) or
       date eq holiday('THANKSGIVING', year(date)) or
       date eq holiday('CHRISTMAS', year(date)) or
       date eq holiday('MEMORIAL', year(date)) or
       date eq holiday('LABOR', year(date)) then do;
      i+1;
      holidays(i)=date;
    end;
    if not(date in holidays or weekday(date) in (1,7)) then do;
      season=1;
      begin=date;
      output;
    end;
  end;
run;

options intervalds=(workdays=wrkdays);

data test;
  days=intck('workdays','1may2017'd,'19may2017'd);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 03:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357366#M83877</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-10T03:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357368#M83879</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;solution will not deal with #2, but to be honest, you should be able to modify the code. I generally don't recommend running code if you don't understand it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming you're referring to day in-lieu days - if XMAS is Sunday then Monday would be a day off as well. The idea seems clear - create a dataset that includes all the dates that would be working dates and then use that as Intervalds option. &amp;nbsp;The variable must be named BEGIN and it needs to be the only variable in the dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22922"&gt;@tparvaiz&lt;/a&gt;&amp;nbsp;Why did you divide the number of days by (60/60/24) in your SQL query? It returns the number of days.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 03:40:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357368#M83879</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-10T03:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357577#M83965</link>
      <description>&lt;P&gt;here is what I did... ran a code similar to the one below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data wrkdays (keep=begin);
  format begin date9.;
  array holidays(6);
  do date = '01jan1971'd to '31dec2070'd ;
    if date eq intnx('year',date,0,'b') then do;
      call missing(of holidays(*));
      i=0;
    end;
    if date eq holiday('NEWYEAR', year(date)) or
       date eq holiday('USINDEPENDENCE',year(date)) or
       date eq holiday('THANKSGIVING', year(date)) or
       date eq holiday('CHRISTMAS', year(date)) or
       date eq holiday('MEMORIAL', year(date)) or
       date eq holiday('LABOR', year(date)) then do;
      i+1;
      holidays(i)=date;
    end;
    if not(date in holidays or weekday(date) in (1,7)) then do;
      season=1;
      begin=date;
      output;
    end;
  end;
run;

options intervalds=(workdays=wrkdays);

data test;&lt;BR /&gt;&lt;BR /&gt;  set DB.v_all_2017&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(where = (&amp;amp;date1 &amp;lt;= sched_dt &amp;lt; &amp;amp;date2));&lt;BR /&gt;  days =intck('workdays','1may2017'd,'19may2017'd);&lt;BR /&gt;  workdays = intck('workdays', start_date, end_date);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-----issue ----------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the count of days are coming just fine but the workdays field is showing 0 values for all the fields&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;----Output ---------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my table looks something like this (with workdays showing 0 values)... it works when I pass a fixed date value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="452"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="155"&gt;Table: v_all_2017&lt;/TD&gt;
&lt;TD width="153"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="80"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;start_date&lt;/TD&gt;
&lt;TD&gt;end_date&lt;/TD&gt;
&lt;TD&gt;workdays&lt;/TD&gt;
&lt;TD&gt;days&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;24JAN2017:09:45:00.000&lt;/TD&gt;
&lt;TD&gt;08FEB2017:15:30:00.000&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;28JAN2017:00:35:00.000&lt;/TD&gt;
&lt;TD&gt;08FEB2017:17:30:00.000&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;03FEB2017:08:49:10.940&lt;/TD&gt;
&lt;TD&gt;07FEB2017:14:35:00.000&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please adviase&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 17:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357577#M83965</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-10T17:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357592#M83975</link>
      <description>&lt;P&gt;Your variables are DATETIME not DATE variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use DATEPART() to convert them to DATE type to pass to the INTCK function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 17:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357592#M83975</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-10T17:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357594#M83976</link>
      <description>it worked with following change&lt;BR /&gt;&lt;BR /&gt; workdays = intck('workdays', datepart(start_date), datepart(end_date));</description>
      <pubDate>Wed, 10 May 2017 17:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357594#M83976</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-10T17:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357599#M83980</link>
      <description>&lt;P&gt;Then please mark&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;solution as the correct answer.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 17:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357599#M83980</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-10T17:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: macro to exclude week end days and company holidays from the count of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357665#M84006</link>
      <description>&lt;P&gt;Thanks again for your assistance&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 20:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-exclude-week-end-days-and-company-holidays-from-the/m-p/357665#M84006</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-10T20:28:58Z</dc:date>
    </item>
  </channel>
</rss>

