<?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 Identifying week numbers from specific dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698810#M213739</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Hello,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; I have dates that start on 3.16.19 and run through 5.31.19, and I'd like to&amp;nbsp;identify the week numbers, starting with 3.16 as 1 all the way through 10. It's currently starting my weeks as 10, as in the 10th week of 2019&amp;nbsp;and since 3/16 is a Saturday, it's starting week 11 starting on 3/17. I'd like:&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;&lt;STRONG&gt;data have:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week10=3/16/20-3/21/20.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week11=3/17-3/23&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week1:3/16-3/23&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week2: 3/24-3/30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3/16 (week1)-3/23; 3/24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week2: 3/24-3/30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3/16 (week1)-3/23; 3/24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week2: 3/24-3/30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3/16 x3/23; 3/24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week2: 3/24-3/30&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Nov 2020 20:44:25 GMT</pubDate>
    <dc:creator>stancemcgraw</dc:creator>
    <dc:date>2020-11-13T20:44:25Z</dc:date>
    <item>
      <title>Identifying week numbers from specific dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698810#M213739</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hello,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; I have dates that start on 3.16.19 and run through 5.31.19, and I'd like to&amp;nbsp;identify the week numbers, starting with 3.16 as 1 all the way through 10. It's currently starting my weeks as 10, as in the 10th week of 2019&amp;nbsp;and since 3/16 is a Saturday, it's starting week 11 starting on 3/17. I'd like:&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;&lt;STRONG&gt;data have:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week10=3/16/20-3/21/20.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week11=3/17-3/23&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week1:3/16-3/23&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week2: 3/24-3/30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3/16 (week1)-3/23; 3/24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week2: 3/24-3/30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3/16 (week1)-3/23; 3/24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week2: 3/24-3/30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3/16 x3/23; 3/24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;week2: 3/24-3/30&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 20:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698810#M213739</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2020-11-13T20:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying week numbers from specific dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698814#M213742</link>
      <description>&lt;P&gt;So just what code are you currently using to get "week" values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know how many "weeks" something should be from a base date you should be able to get that using the INTCK and INTNX functions. I can't provide any code as you haven't said exactly when your week one should start and possibly which day of the week should be the first of the new week.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 21:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698814#M213742</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-13T21:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying week numbers from specific dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698827#M213747</link>
      <description>&lt;P&gt;There are recognised international standards defining week numbers. The SAS WEEK function can provide some of these:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=ds2ref&amp;amp;docsetTarget=n09mp3mz73ue0un16gmazw40der7.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=ds2ref&amp;amp;docsetTarget=n09mp3mz73ue0un16gmazw40der7.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 22:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698827#M213747</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-11-13T22:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying week numbers from specific dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698895#M213780</link>
      <description>&lt;P&gt;I was initially using the week function as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WEEK=WEEK(date of arrival), but my date range includes 3/16/20-5/31/20, so that function outputs this:&lt;/P&gt;&lt;P&gt;data have:&lt;/P&gt;&lt;P&gt;week &amp;nbsp; &amp;nbsp;date of arrival&lt;/P&gt;&lt;P&gt;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3/16/2019&lt;/P&gt;&lt;P&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3/17/2019&lt;/P&gt;&lt;P&gt;11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3/22/2019&lt;/P&gt;&lt;P&gt;12 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3/24/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want:&lt;/P&gt;&lt;P&gt;week &amp;nbsp; &amp;nbsp; &amp;nbsp;date of arrival&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3/16/2019&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3/17/2019&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3/22/2019&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3/24/2019&lt;/P&gt;</description>
      <pubDate>Sat, 14 Nov 2020 18:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698895#M213780</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2020-11-14T18:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying week numbers from specific dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698921#M213786</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/78398"&gt;@stancemcgraw&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;week=ceil((date-'15MAR2019'd)/7);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Equivalently (for your date range) you can use the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;INTCK function&lt;/A&gt; (with the shifted interval &lt;FONT face="courier new,courier"&gt;'week.7'&lt;/FONT&gt; -- weeks starting on Saturdays), as suggested by &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_blank" rel="noopener"&gt;ballardw&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;week=intck('week.7','15MAR2019'd, date);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n1ka2ulrvrjlasn0z7beco2yrgas.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;WEEK function&lt;/A&gt;, as suggested by &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976" target="_blank" rel="noopener"&gt;SASKiwi&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;week=week(date-69);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The "magic" number 69 can be computed as&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'16MAR2019'd-nwkdom(1,1,1,2019)&lt;/FONT&gt;, i.e., the difference (in days) between the&amp;nbsp;first day of week 1 in your date range&amp;nbsp;and the first day of week 1 of 2019 according to the&amp;nbsp;WEEK function&amp;nbsp;(with the default "descriptor").&lt;/P&gt;</description>
      <pubDate>Sat, 14 Nov 2020 23:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-week-numbers-from-specific-dates/m-p/698921#M213786</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-11-14T23:15:09Z</dc:date>
    </item>
  </channel>
</rss>

