<?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: Number of working days left in a month from today. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854613#M37658</link>
    <description>&lt;P&gt;In general you want to clearly define what you want. &lt;STRONG&gt;Your&lt;/STRONG&gt; "working day" may not be my working day. I know organizations that consider weekends working days but not Monday. My dentist doesn't work on Friday. At least one company I worked for that normally worked on Sundays didn't on Super Bowl Sunday, and another closed for the first week of deer hunting season.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example for one date does not provide a general rule that could be applied to all months without such details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, your pseudo-code is not using order of operations correctly.&lt;/P&gt;
&lt;PRE&gt;data _null_;
  drr = 130 - 76/9;
  put drr=;
run;&lt;/PRE&gt;
&lt;P&gt;shows Drr= 121.55555556 (approximately).&lt;/P&gt;
&lt;P&gt;So your Drr calculation is drr = ( 130 - 76)/9;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jan 2023 15:41:49 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-01-19T15:41:49Z</dc:date>
    <item>
      <title>Number of working days left in a month from today.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854512#M37650</link>
      <description>&lt;P&gt;I was working on SAS and I need to calculate expected approved per day in order to achieve the target.&lt;/P&gt;
&lt;P&gt;So what I did is below but I got stuck at one point.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input target Approved;
datalines;
130 76
130 88
120 45
130 23
130 99
;

data DRR;
set have;
DRR = target - approved / No. of working days left;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want a logic for Number of working days left in a month from today.&lt;BR /&gt;For Example: Today is 19JAN2023.therefore, Number of working days left is 9.If, we exclude&amp;nbsp;&lt;BR /&gt;Hence, for the first observation DRR would be &lt;BR /&gt;DRR = 130-76/9 = 6.&lt;BR /&gt;Please, help.&lt;/P&gt;
&lt;P&gt;Thanks to all the contributors to this query in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 09:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854512#M37650</guid>
      <dc:creator>Kirito1</dc:creator>
      <dc:date>2023-01-19T09:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Number of working days left in a month from today.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854571#M37656</link>
      <description>&lt;P&gt;Try adding this to your code . This will help figure out how many weekdays left available in the month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format endofmonth date9.;&lt;BR /&gt;endofmonth=intnx("month",today(),0,"end");&lt;BR /&gt;wdleft=intck("weekdays",today(),endofmonth+1,"c");&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 13:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854571#M37656</guid>
      <dc:creator>CarmineVerrell</dc:creator>
      <dc:date>2023-01-19T13:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Number of working days left in a month from today.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854574#M37657</link>
      <description>&lt;P&gt;A number of years ago &lt;A href="https://blogs.sas.com/content/sasdummy/2011/05/09/calculating-the-number-of-working-days-between-two-dates/" target="_self"&gt;I wrote an example&lt;/A&gt; of the NETWORKDAYS function in SAS (it exists &lt;A href="https://support.microsoft.com/en-us/office/networkdays-function-48e717bf-a7a3-495f-969e-5005e3eb18e7" target="_self"&gt;in Excel&lt;/A&gt;). This function counts weekdays (as in the example by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/23738"&gt;@CarmineVerrell&lt;/a&gt;) and also considers holidays (as supplied in a data set you specify).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;/* setup some holiday data */
DATA WORK.usholidays;
    length
        HolidayDate             8
        Comment               $ 27;
    format
        HolidayDate           DATE9.
        Comment               $CHAR27.;
    infile datalines 
        dlm=',' 
        missover
        dsd;
    input
        HolidayDate           : mmddyy12.
        Comment               : $CHAR27.;
datalines;
1/1/2010,New Year's Day
1/18/2010,Birthday of Martin Luther King Jr.
5/31/2010,Memorial Day
7/4/2010,Independence Day
7/5/2010,Independence Day (obs)
9/6/2010,Labor Day
10/11/2010,Columbus Day
11/8/2010,Veterans Day
11/25/2010,Thanksgiving Day
12/25/2010,Christmas Day
1/1/2010,New Year's Day
1/17/2011,Birthday of Martin Luther King Jr.
5/30/2011,Memorial Day
7/4/2011,Independence Day
9/5/2011,Labor Day
10/10/2011,Columbus Day
11/11/2011,Veterans Day
11/24/2011,Thanksgiving Day
12/25/2011,Christmas Day
2/21/2012,Washington's Birthday
1/1/2012,New Year's Day
1/2/2012,New Year's Day
1/17/2012,Birthday of Martin Luther King Jr.
2/20/2012,Washington's Birthday
5/28/2012,Memorial Day
7/4/2012,Independence Day
9/3/2012,Labor Day
10/8/2012,Columbus Day
11/12/2012,Veterans Day
11/22/2012,Thanksgiving Day
12/25/2012,Christmas Day
; 
run;

/*
 * Mimic the NETWORKDAYS example here:
 *   https://support.microsoft.com/en-us/office/networkdays-function-48e717bf-a7a3-495f-969e-5005e3eb18e7
 */
proc fcmp  outlib=work.myfuncs.dates;
  function networkdays(d1,d2,holidayDataset $,dateColumn $);

    /* make sure the start date &amp;lt; end date */
    start_date = min(d1,d2);
    end_date = max(d1,d2);

    /* read holiday data into array */
    /* array will resize as necessary */
    array holidays[1] / nosymbols;
    if (not missing(holidayDataset) and exist(holidayDataset)) then
        rc = read_array(holidayDataset, holidays, dateColumn);
    else put "NOTE: networkdays(): No Holiday data considered";

    /* INTCK computes transitions from one day to the next */
    /* To include the start date, if it is a weekday, then */
    /*  make the start date one day earlier.               */
    if (1 &amp;lt; weekday(start_date)&amp;lt; 7) then start_date = start_date-1;
    diff = intck('WEEKDAY', start_date, end_date);
    do i = 1 to dim(holidays);
      if (1 &amp;lt; weekday(holidays[i])&amp;lt; 7) and
         (start_date &amp;lt;= holidays[i] &amp;lt;= end_date) then
            diff = diff - 1;
    end;
    return(diff);
  endsub;
run; quit;

options cmplib=work.myfuncs;

/* test with one value */
data _null_;
  start_date = '31DEC2010'd;
  end_date = '31MAY2011'd;
  days = networkdays(start_date, end_date, "work.usholidays","holidaydate");
  put days=;
run;

/* test with data set of values */
data test;
  length dates 8;
  format dates date9.;
  infile datalines dsd;
  input dates : date9.;
  workdaysSince = networkdays(dates, today(), "work.usholidays","holidaydate");
datalines;
01NOV2010
21NOV2010
01DEC2010
01APR2011
;
title "As of &amp;amp;SYSDATE";
proc print data=test; run;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 13:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854574#M37657</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-01-19T13:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Number of working days left in a month from today.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854613#M37658</link>
      <description>&lt;P&gt;In general you want to clearly define what you want. &lt;STRONG&gt;Your&lt;/STRONG&gt; "working day" may not be my working day. I know organizations that consider weekends working days but not Monday. My dentist doesn't work on Friday. At least one company I worked for that normally worked on Sundays didn't on Super Bowl Sunday, and another closed for the first week of deer hunting season.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example for one date does not provide a general rule that could be applied to all months without such details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, your pseudo-code is not using order of operations correctly.&lt;/P&gt;
&lt;PRE&gt;data _null_;
  drr = 130 - 76/9;
  put drr=;
run;&lt;/PRE&gt;
&lt;P&gt;shows Drr= 121.55555556 (approximately).&lt;/P&gt;
&lt;P&gt;So your Drr calculation is drr = ( 130 - 76)/9;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 15:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-of-working-days-left-in-a-month-from-today/m-p/854613#M37658</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-19T15:41:49Z</dc:date>
    </item>
  </channel>
</rss>

