<?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: Considering weekend when measuring days until event in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951269#M371883</link>
    <description>&lt;P&gt;Ah, that makes sense. Sorry I didn't catch that, I was on the wrong calendar year so didn't see it was a Sunday.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will assume it is an input error. Thanks for all the help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Nov 2024 21:18:41 GMT</pubDate>
    <dc:creator>sasgorilla</dc:creator>
    <dc:date>2024-11-19T21:18:41Z</dc:date>
    <item>
      <title>Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951165#M371861</link>
      <description>&lt;P&gt;I have a data set with two dates. The first indicates when an event happened (date1). The second when an event resolved (date2).&amp;nbsp;Resolution can only take place on a weekday due to business hours.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to figure out the best way to code in a data step to measure days until resolution (timetores) if:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1)&lt;/STRONG&gt; I decide I want to not count the first weekend days only if date1 was on a weekend (i.e. weekday in (1 7)).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In other words, if date1 was on a Saturday or Sunday and date 2 was on a Monday I would want timetores to =0, as Monday was the first day with the opportunity to resolve. This timetores should be the same as if date1 and date 2 were on the same weekday. In either scenario, days after the first Monday or subsequent weekday would add +1 day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Weekend days following the first weekend, or any weekdays if Date1 occurred on a weekday, would add +1 day as with any other day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2)&lt;/STRONG&gt; Alternatively, how would I code if I decide I want to not count any weekend days, regardless of when Date 1 took place.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example I basically wouldn't penalize days where resolution could not take place. So if Date1 took place on Friday, the next Monday should start with 1. If date1 took place on a Monday, the following Monday timetores would =5 (Tue=1, Wed=2, Thu=3, Fri=4, Mon=5).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this make sense?&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, 19 Nov 2024 01:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951165#M371861</guid>
      <dc:creator>sasgorilla</dc:creator>
      <dc:date>2024-11-19T01:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951178#M371863</link>
      <description>&lt;P&gt;I think you can do this - just set %let penalize_weekends to 0 or 1 (i.e., false / true) as needed (first bit is just some fake data):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
do i=1 to 20;
	dt1='02Nov2024'd;
	dt2=dt1+i;
	output;
end;
drop i;
format dt1 dt2 date9.;
run;

%let penalize_weekends=0;

data want;
set have;
DT=dt1+(weekday(dt1)=7)*2+(weekday(dt1)=1);
timetores=0;
do while (DT&amp;lt;dt2);
    timetores+(weekday(DT)&amp;lt;6)+(weekday(DT)&amp;gt;5)*&amp;amp;penalize_weekends;
    DT+1;
end;
drop DT;
run;

proc print data=want; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2024 02:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951178#M371863</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2024-11-19T02:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951180#M371864</link>
      <description>&lt;P&gt;That would be better if you could post some example and desired output to illustrate what you are looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input start :yymmdd10. end :yymmdd10.;
_start=start;
if weekday(start)=1 then _start=start+1;
if weekday(start)=7 then _start=start+2;
want=intck('weekday',_start,end);
drop _start;
format start end yymmdd10.;
cards;
2024-11-16 2024-11-18
2024-11-17 2024-11-18
2024-11-11 2024-11-18
2024-11-18 2024-11-18
2024-11-18 2024-11-19
;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2024 02:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951180#M371864</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-11-19T02:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951184#M371865</link>
      <description>&lt;P&gt;It's always really helpful if sample data gets provided. Assuming I did create correct sample data below should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input event_dt:date9. resolve_dt:date9. days2resolve_want;
  format event_dt resolve_dt date9.;
  datalines;
15nov2024 18nov2024 1
16nov2024 18nov2024 0
17nov2024 18nov2024 0
18nov2024 18nov2024 0
16nov2024 19nov2024 1
17nov2024 19nov2024 1
18nov2024 19nov2024 1
18nov2024 20nov2024 2
15nov2024 26nov2024 7
16nov2024 26nov2024 6
17nov2024 26nov2024 6
18nov2024 26nov2024 6
19nov2024 26nov2024 5
;

data want;
  set have;
  if weekday(event_dt) in (1,7) then days2resolve_derived=intck('weekday17w',intnx('weekday17w',event_dt,1),resolve_dt);
  else days2resolve_derived=intck('weekday17w',event_dt,resolve_dt);
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1731983318711.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102342i3B1F5B43B8AE8504/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1731983318711.png" alt="Patrick_0-1731983318711.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 02:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951184#M371865</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-11-19T02:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951207#M371870</link>
      <description>&lt;P&gt;You are right, sorry for not including code for clarity. Please see below.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date1 :yymmdd10. date2 :yymmdd10.;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04
2024-11-04 2024-11-04
2024-11-05 2024-11-07
2024-11-07 2024-11-11
;
RUN;

data want1 /*don't count only 1st weekend if date1 on 1st weekend*/;
input date1 :yymmdd10. date2 :yymmdd10. timetores;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04 0
2024-11-04 2024-11-04 0
2024-11-05 2024-11-07 2
2024-11-07 2024-11-11 4
2024-11-09 2024-11-18 7
;
RUN;

data want2 /*never count weekend*/;
input date1 :yymmdd10. date2 :yymmdd10. timetores;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04 0
2024-11-04 2024-11-04 0
2024-11-05 2024-11-07 2
2024-11-07 2024-11-11 2
2024-11-09 2024-11-18 5
;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2024 11:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951207#M371870</guid>
      <dc:creator>sasgorilla</dc:creator>
      <dc:date>2024-11-19T11:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951209#M371871</link>
      <description>&lt;P&gt;Thank you, Patrick. It looks like the code you provided works out the 2nd "want". I will read up on intck and intnx, as I don't think I've seen these before.&amp;nbsp; I've attached code below to clarify the difference between the 1st and 2nd want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date1 :yymmdd10. date2 :yymmdd10.;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04
2024-11-04 2024-11-04
2024-11-05 2024-11-07
2024-11-07 2024-11-11
;
RUN;

data want1 /*don't count only 1st weekend if date1 on 1st weekend*/;
input date1 :yymmdd10. date2 :yymmdd10. timetores;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04 0
2024-11-04 2024-11-04 0
2024-11-05 2024-11-07 2
2024-11-07 2024-11-11 4
2024-11-09 2024-11-18 7
;
RUN;

data want2 /*never count weekend*/;
input date1 :yymmdd10. date2 :yymmdd10. timetores;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04 0
2024-11-04 2024-11-04 0
2024-11-05 2024-11-07 2
2024-11-07 2024-11-11 2
2024-11-09 2024-11-18 5
;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2024 11:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951209#M371871</guid>
      <dc:creator>sasgorilla</dc:creator>
      <dc:date>2024-11-19T11:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951211#M371872</link>
      <description>&lt;P&gt;Thank you, quickbluefish. This produces the 2nd want (see the code I added in another reply to clarify between the two approaches I am looking for). It is good to see different ways to approach this problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 11:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951211#M371872</guid>
      <dc:creator>sasgorilla</dc:creator>
      <dc:date>2024-11-19T11:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951264#M371879</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/458102"&gt;@sasgorilla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you, Patrick. It looks like the code you provided works out the 2nd "want". I will read up on intck and intnx, as I don't think I've seen these before.&amp;nbsp; I've attached code below to clarify the difference between the 1st and 2nd want.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For working with dates understanding intnx() and intck() is crucial and will make your programming live much easier.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below amended code for calculation of both your wants.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* timetores_1: don't count only 1st weekend if date1 on 1st weekend */
/* timetores_1: never count weekend                                  */
data have;
  input date1 :yymmdd10. date2 :yymmdd10. timetores_1 timetores_2;
  format date1 yymmdd10. date2 yymmdd10.;
  datalines;
2024-11-02 2024-11-04 0 0
2024-11-04 2024-11-04 0 0
2024-11-05 2024-11-07 2 2
2024-11-07 2024-11-11 4 2
2024-11-09 2024-11-18 7 5
;
run;

data want;
  set have;

  shift_date1=date1;

  /* if shift_date1 a Saturday or Sunday shift it to Monday */
  if weekday(shift_date1) in (1,7) then shift_date1=intnx('weekday17w',shift_date1,1);

  derived_timetores_1=date2-shift_date1;
  /* derived_timetores_1=intck('day',shift_date1,date2); */

  derived_timetores_2=intck('weekday17w',shift_date1,date2);

run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 20:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951264#M371879</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-11-19T20:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951265#M371880</link>
      <description>&lt;P&gt;Thanks, Patrick! This appears to have worked except there is one particular observation that is (-) for both values, (-2) for want1 and (-1) for want2. This is the only negative value out of a couple thousand observations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this observation, Date1=04/09/2022 and Date 2=04/09/2022;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas on how to troubleshoot to figure out what's causing this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 20:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951265#M371880</guid>
      <dc:creator>sasgorilla</dc:creator>
      <dc:date>2024-11-19T20:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951267#M371881</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/458102"&gt;@sasgorilla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks, Patrick! This appears to have worked except there is one particular observation that is (-) for both values, (-2) for want1 and (-1) for want2. This is the only negative value out of a couple thousand observations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this observation, Date1=04/09/2022 and Date 2=04/09/2022;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas on how to troubleshoot to figure out what's causing this?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's because your Date2 is on a Sunday which is obviously not a working day and though based on your initial definition shouldn't be possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have to cater for such cases then you need to provide amended sample data that covers such cases, shows the desired result and explains the logic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* timetores_1: don't count only 1st weekend if date1 on 1st weekend */
/* timetores_1: never count weekend                                  */
data have;
  input date1 :yymmdd10. date2 :yymmdd10. timetores_1 timetores_2;
  format date1 yymmdd10. date2 yymmdd10.;
  datalines;
2024-11-02 2024-11-04 0 0
2024-11-04 2024-11-04 0 0
2024-11-05 2024-11-07 2 2
2024-11-07 2024-11-11 4 2
2024-11-09 2024-11-18 7 5
2022-09-04 2022-09-04 0 0
;
run;

data want;
  set have;
  format date1 date2 shift_date1 weekdatx.;

  shift_date1=date1;

  /* if shift_date1 a Saturday or Sunday shift it to Monday */
  if weekday(shift_date1) in (1,7) then shift_date1=intnx('weekday17w',shift_date1,1);

  derived_timetores_1=date2-shift_date1;
  /* derived_timetores_1=intck('day',shift_date1,date2); */

  derived_timetores_2=intck('weekday17w',shift_date1,date2);

run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1732050464223.png" style="width: 766px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/102357i1972E3614BB77CE0/image-dimensions/766x136?v=v2" width="766" height="136" role="button" title="Patrick_0-1732050464223.png" alt="Patrick_0-1732050464223.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951267#M371881</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-11-19T21:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951268#M371882</link>
      <description>&lt;P&gt;Your have data set has 4 records, but your want data sets have 5 records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure for want2, the last one should be 5, not 6? If it is 6, I think this mostly works.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

timestores = intck('weekday', date1, date2);

*if start on weekend, move to first weekday;
if weekday(date1) in (1,7) then date_start = intnx('weekday', date1, 1, 'b');
else date_start = date1;

format date_start yymmdd10.;

*second calculation;
timestores2 = intck('day', date_start, date2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/458102"&gt;@sasgorilla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You are right, sorry for not including code for clarity. Please see below.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date1 :yymmdd10. date2 :yymmdd10.;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04
2024-11-04 2024-11-04
2024-11-05 2024-11-07
2024-11-07 2024-11-11
;
RUN;

data want1 /*don't count only 1st weekend if date1 on 1st weekend*/;
input date1 :yymmdd10. date2 :yymmdd10. timetores;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04 0
2024-11-04 2024-11-04 0
2024-11-05 2024-11-07 2
2024-11-07 2024-11-11 4
2024-11-09 2024-11-18 7
;
RUN;

data want2 /*never count weekend*/;
input date1 :yymmdd10. date2 :yymmdd10. timetores;
format date1 yymmdd10. date2 yymmdd10.;
datalines;
2024-11-02 2024-11-04 0
2024-11-04 2024-11-04 0
2024-11-05 2024-11-07 2
2024-11-07 2024-11-11 2
2024-11-09 2024-11-18 5
;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951268#M371882</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-11-19T21:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951269#M371883</link>
      <description>&lt;P&gt;Ah, that makes sense. Sorry I didn't catch that, I was on the wrong calendar year so didn't see it was a Sunday.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will assume it is an input error. Thanks for all the help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951269#M371883</guid>
      <dc:creator>sasgorilla</dc:creator>
      <dc:date>2024-11-19T21:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951270#M371884</link>
      <description>&lt;P&gt;Sorry, that was a mistake to not include the 5th line of code in the HAVE dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for pointing that out!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951270#M371884</guid>
      <dc:creator>sasgorilla</dc:creator>
      <dc:date>2024-11-19T21:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Considering weekend when measuring days until event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951272#M371886</link>
      <description>&lt;P&gt;You could add some error handling for such cases. Something like:&lt;/P&gt;
&lt;PRE&gt;if weekday(date2) in (1,7) then
  do;
  /* here some error handling code */
  end;
&lt;/PRE&gt;
&lt;P&gt;You could for example ensure that your time_stores variables become missing if date2 falls on a weekend and though is invalid. Or you could&amp;nbsp; "fix" the data and shift it on to the next Monday.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  format date1 date2 shift_date1 shift_date2 weekdatx.;

  shift_date1=date1;
  shift_date2=date2;

  if weekday(shift_date2) in (1,7) then
  do;
    /* Option1: set shift_date2 to missing so derived variables become missing */
    /* shift_date2=.; */

    /* Option2: "fix" data by shifting date2 to Monday */
    shift_date2=intnx('weekday17w',shift_date2,1);
  end;


  /* if shift_date1 a Saturday or Sunday shift it to Monday */
  if weekday(shift_date1) in (1,7) then shift_date1=intnx('weekday17w',shift_date1,1);

  derived_timetores_1=shift_date2-shift_date1;
  /* derived_timetores_1=intck('day',shift_date1,shift_date2); */

  derived_timetores_2=intck('weekday17w',shift_date1,shift_date2);

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Considering-weekend-when-measuring-days-until-event/m-p/951272#M371886</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-11-19T21:41:25Z</dc:date>
    </item>
  </channel>
</rss>

