<?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: INTCK weekdays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INTCK-weekdays/m-p/521989#M141665</link>
    <description>&lt;P&gt;Explain what you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to generate all of the weekdays between start and end?&lt;/P&gt;
&lt;P&gt;Do you just want to test if start and/or end is a weekday?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  do offset=0 to intck('day',start_date,end_date);
    new =intnx('day', start_date, offset);
    if weekday(new) in ( 2:6 ) then output;
  end;
  format new date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If you want to count by week days you could use the WEEKDAY interval instead.&amp;nbsp; But then you need to check whether to start counting from zero or one based on whether your start date is a week day or not.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want2;
  set have;
  do offset=start_date ne intnx('weekday',start_date,0) to intck('weekday',start_date,end_date);
    new =intnx('weekday', start_date, offset);
    output;
  end;
  format new date9.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Dec 2018 18:24:56 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-12-17T18:24:56Z</dc:date>
    <item>
      <title>INTCK weekdays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTCK-weekdays/m-p/521878#M141629</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a very basic question I guess. I'm completely new to SAS.&lt;/P&gt;&lt;P&gt;Well, I have a table with 66'814 observations of start and end dates and I need to get only the weekdays.&amp;nbsp;The variables are named start_date and end_date.&lt;/P&gt;&lt;P&gt;I tried the intck (weekday) function, but it didn't actually work the way I thought it would.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; weekday(star_date) in(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;7&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;new = intck(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"weekday"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, start_date, end_date);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;new = intck(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"weekday"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, start_date-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;, end_date);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error appeared&amp;nbsp;that start_date and end_date aren't initalized.&lt;/P&gt;&lt;P&gt;All the solutions I found looked like I have to use this function above for each observation seperately, but that would took hours to do so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any help.&lt;/P&gt;&lt;P&gt;Best wishes.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 11:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTCK-weekdays/m-p/521878#M141629</guid>
      <dc:creator>Psychoberry</dc:creator>
      <dc:date>2018-12-17T11:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK weekdays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTCK-weekdays/m-p/521880#M141630</link>
      <description>&lt;P&gt;The log is telling you that those variables dont exist.&amp;nbsp; Even a brief look at the code you show shows that in the weekday function you use a variable called star_day, and then in the rest of the code start_date = different.&amp;nbsp; If you want help, post test data in the form of a datastep:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show what you want out from that test data.&amp;nbsp; Show all your code around the block in question, show the log of that part etc.&amp;nbsp; This is not a guessing game!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 11:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTCK-weekdays/m-p/521880#M141630</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-17T11:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: INTCK weekdays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTCK-weekdays/m-p/521989#M141665</link>
      <description>&lt;P&gt;Explain what you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to generate all of the weekdays between start and end?&lt;/P&gt;
&lt;P&gt;Do you just want to test if start and/or end is a weekday?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  do offset=0 to intck('day',start_date,end_date);
    new =intnx('day', start_date, offset);
    if weekday(new) in ( 2:6 ) then output;
  end;
  format new date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If you want to count by week days you could use the WEEKDAY interval instead.&amp;nbsp; But then you need to check whether to start counting from zero or one based on whether your start date is a week day or not.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want2;
  set have;
  do offset=start_date ne intnx('weekday',start_date,0) to intck('weekday',start_date,end_date);
    new =intnx('weekday', start_date, offset);
    output;
  end;
  format new date9.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Dec 2018 18:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTCK-weekdays/m-p/521989#M141665</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-17T18:24:56Z</dc:date>
    </item>
  </channel>
</rss>

