<?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: exploring code to calculate working days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450585#M113456</link>
    <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  do i=intnx('month',today(),0,'beginning') to intnx('month',today(),0,'end');
    if weekday(i) ne 1 then tot=sum(tot,1);
  end;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 03 Apr 2018 12:17:36 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-04-03T12:17:36Z</dc:date>
    <item>
      <title>exploring code to calculate working days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450578#M113452</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am exploring for code to calculate the the total no of working days in a month excluding sundays only.&lt;/P&gt;&lt;P&gt;i.e start date should be 1st date of every month and the end date should be last day of every month and calculate net working days in the current month. As the code should fetch the current month and calculate accordingly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 11:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450578#M113452</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T11:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: exploring code to calculate working days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450582#M113454</link>
      <description>&lt;P&gt;Remove all days where the weekday() function returns Saturday or Sunday.&lt;/P&gt;
&lt;P&gt;Remove all days that can somehow be detected with the SAS holiday() function.&lt;/P&gt;
&lt;P&gt;Remove all days that are country-specific or otherwise happen on a fixed date (May 1st, Christmas, New Year).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How you do it depends on how you need to use the result in further code.&lt;/P&gt;
&lt;P&gt;For instance, you could create a table for a whole year (or a given timespan), and then create a custom format off that.&lt;/P&gt;
&lt;P&gt;You could then create a macro&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro num_workdays(month,year);
%local i;
%let i = 0;
%do day = %sysfunc(mdy(&amp;amp;month.,1,&amp;amp;year.)) %to %sysfunc(intnx(month,%sysfunc(mdy(&amp;amp;month.,1,&amp;amp;year.)),0,e));
  %if %sysfunc(putn(&amp;amp;day.,myholiday.)) %then %let i = %eval(&amp;amp;i. + 1);
%end;
&amp;amp;i.
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 12:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450582#M113454</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-03T12:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: exploring code to calculate working days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450585#M113456</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  do i=intnx('month',today(),0,'beginning') to intnx('month',today(),0,'end');
    if weekday(i) ne 1 then tot=sum(tot,1);
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 12:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450585#M113456</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-03T12:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: exploring code to calculate working days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450594#M113460</link>
      <description>Thanks ... worked.</description>
      <pubDate>Tue, 03 Apr 2018 12:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exploring-code-to-calculate-working-days/m-p/450594#M113460</guid>
      <dc:creator>anirudhs</dc:creator>
      <dc:date>2018-04-03T12:30:29Z</dc:date>
    </item>
  </channel>
</rss>

