<?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 How to find the number of Sundays between two dates? in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/398977#M3519</link>
    <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Using appropriate SAS DATE functions and maybe PROC FREQ, find a frequency table containing the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;number of Sundays (1), Mondays (2), ...., Saturdays (7) in the year 2017. You can enter your data/dates in any format you want.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2017 23:48:03 GMT</pubDate>
    <dc:creator>alilacey0</dc:creator>
    <dc:date>2017-09-26T23:48:03Z</dc:date>
    <item>
      <title>How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/398977#M3519</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Using appropriate SAS DATE functions and maybe PROC FREQ, find a frequency table containing the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;number of Sundays (1), Mondays (2), ...., Saturdays (7) in the year 2017. You can enter your data/dates in any format you want.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 23:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/398977#M3519</guid>
      <dc:creator>alilacey0</dc:creator>
      <dc:date>2017-09-26T23:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/398980#M3520</link>
      <description>&lt;P&gt;Homework, eh?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2017 23:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/398980#M3520</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-26T23:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/398990#M3522</link>
      <description>&lt;P&gt;I think homework questions are fine.&amp;nbsp; But as with any other question, it's important for you to two show what code you have tried, and describe how your code failed (errors in the log? incorrect results?)&amp;nbsp; By posting your code, people can identify the error your made and help you understand the error (and correct it).&amp;nbsp; By posting your code, you help people help you.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 00:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/398990#M3522</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-09-27T00:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399011#M3526</link>
      <description>&lt;P&gt;this is what I have so far, but we are having troubles getting the days of the week for 2017&lt;/P&gt;&lt;P&gt;I attached some of our results as well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(this does not run)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;data dates;&lt;BR /&gt;do i=1 to 365;&lt;BR /&gt;Sundays = intck('weekday', '01Jan2017'd, '31Dec2017'd);&lt;BR /&gt;day = weekday(week);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;title "Number of Each Day of the Week in 2017";&lt;BR /&gt;proc print data == dates noobs;&lt;BR /&gt;var week Day -- Year;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;(this does run but not able to get any further, results are attached)&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;data days;&lt;/DIV&gt;&lt;DIV&gt;do i=0 to 365;&lt;/DIV&gt;&lt;DIV&gt;Day = intck('week', '01Jan2017'd, '31Dec2017'd);&lt;/DIV&gt;&lt;DIV&gt;end;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;title "Listing of Days of the Week for 2017";&lt;/DIV&gt;&lt;DIV&gt;proc print data=days noob;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 27 Sep 2017 03:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399011#M3526</guid>
      <dc:creator>alilacey0</dc:creator>
      <dc:date>2017-09-27T03:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399027#M3531</link>
      <description>Does the first data-step what you expected? There should be at least notes about missing values in the log.&lt;BR /&gt;&lt;BR /&gt;The following untested code (send from my mobile phone) should create a dataset to start with:&lt;BR /&gt;data dates;&lt;BR /&gt;do date = "1Jan2017"d to "31Dec2017"d;&lt;BR /&gt;dow = weekday(date);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Now have a look a the documentation of proc freq ... the task should be easy to solve.</description>
      <pubDate>Wed, 27 Sep 2017 05:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399027#M3531</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-09-27T05:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399067#M3533</link>
      <description>&lt;P&gt;In the interests of full disclosure (and not wanting to commit plagiarism) I found this answer on stackoverflow&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/40676721/number-of-sundays-between-two-dates" target="_blank"&gt;https://stackoverflow.com/questions/40676721/number-of-sundays-between-two-dates&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	format a b date9.;
	a='01 nov 2016'd;
	b='18 nov 2016'd;
	Sundays = intck('weekday234567w',a,b);
	put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Sep 2017 08:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399067#M3533</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-27T08:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399240#M3536</link>
      <description>&lt;P&gt;The INTCK('week',from_date,to_date) will count the number of saturday/sunday boundaries crossed between from_date through to_date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So consider;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; n_sun2017=intck('week','31dec2016'd,'31dec2017'd);&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;or equivalently use the "week.1" interval descriptor.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp; n_sun2017=intck('week.1','31dec2016'd,'31dec2017'd);&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Number of Monday's?&amp;nbsp; Then you need to count the number of sun/mon boundaries, so use the "week.2" interval descriptor:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; n_mon2017=intck('week.2','31dec2016'd,'31dec2017'd);&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 15:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399240#M3536</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-27T15:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399432#M3537</link>
      <description>&lt;P&gt;Try this.....&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  start='01jan2016'd; end='31dec2016'd; output;
  start='01jan2017'd; end='31dec2017'd; output;
run;

data want;
  set have;
 sunday=0;
do i=start to end;
  sunday=ifn(weekday(i)=1, sum(sunday,1),sunday);
  retain sunday;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 08:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399432#M3537</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-09-28T08:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the number of Sundays between two dates?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399684#M3540</link>
      <description>&lt;P&gt;Just note that when using the INTCK function to count a particular day-of-week, the "from" date should be the day before the actual start of interval.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider&amp;nbsp;'03jan2016'd and '10jan2016'd which are both Sunday, so for that date range you would want N_SUN=2.&amp;nbsp; But&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start='03jan2016'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end='10jan2016'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;n_sun=intck('week.1',start,end)&amp;nbsp;&amp;nbsp;==&amp;gt; 1&amp;nbsp;&amp;nbsp; (not 2)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;or identically&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;n_sun=intck('weekday234567w',start,end) = 1&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;EM&gt;n_sun=intck('week.1',&lt;STRONG&gt;start-1&lt;/STRONG&gt;,end)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 02:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-find-the-number-of-Sundays-between-two-dates/m-p/399684#M3540</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-29T02:53:06Z</dc:date>
    </item>
  </channel>
</rss>

