<?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: How to find the week number of a month? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489861#M127999</link>
    <description>Hi I tried the below and it worked with no issues&lt;BR /&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input date:anydtdte.;&lt;BR /&gt;weeknum = ceil(day(date) / 7);&lt;BR /&gt;format date date9.;&lt;BR /&gt;cards;&lt;BR /&gt;20021030&lt;BR /&gt;;</description>
    <pubDate>Sun, 26 Aug 2018 03:07:44 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2018-08-26T03:07:44Z</dc:date>
    <item>
      <title>How to find the week number of a month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489824#M127979</link>
      <description>&lt;P&gt;Hi, everyone&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I have a data format "20180825" for the Date column, how do I find the week number of the month for that date (i.e. the fourth week of Aug in 2018)? I need your help for this question ASAP. Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Aug 2018 14:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489824#M127979</guid>
      <dc:creator>AndyTeng</dc:creator>
      <dc:date>2018-08-25T14:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the week number of a month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489826#M127980</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date:anydtdte.;
 week=intck('week',intnx('month',date,0),date)+1; 
format date date9.;
cards;
20180825
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Aug 2018 14:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489826#M127980</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-25T14:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the week number of a month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489847#M127992</link>
      <description>&lt;P&gt;If you need the answer ASAP, you should provide the rest of the relevant information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your date variable an eight-digit number, or is it an eight-digit character string, or is it already a SAS date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is your definition of a week?&amp;nbsp; Are the first seven days of the month all in week 1?&amp;nbsp; Even if the first of the month is Wednesday?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on your answers, here is a formula that might come in handy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;weeknum = ceil(day(datevar) / 7);&lt;/P&gt;</description>
      <pubDate>Sat, 25 Aug 2018 21:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489847#M127992</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-25T21:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the week number of a month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489848#M127993</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;Sir, elegance personified. Very neat!&lt;/P&gt;</description>
      <pubDate>Sat, 25 Aug 2018 21:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489848#M127993</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-25T21:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the week number of a month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489860#M127998</link>
      <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;Hi, Astounding&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thank you for your reply.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Yes, I think it's a eight-digit number. I don't have definite definition for the week number of a month. It would be fine if the program can help to show the sequence of a week within a month. BTW, I got the following message by implementing your suggested code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;NOTE: Invalid argument to function DAY(20021030) at line 1998 column 33.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;If you have any suggestion, please let me know. Thank you very much.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Aug 2018 02:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489860#M127998</guid>
      <dc:creator>AndyTeng</dc:creator>
      <dc:date>2018-08-26T02:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the week number of a month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489861#M127999</link>
      <description>Hi I tried the below and it worked with no issues&lt;BR /&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input date:anydtdte.;&lt;BR /&gt;weeknum = ceil(day(date) / 7);&lt;BR /&gt;format date date9.;&lt;BR /&gt;cards;&lt;BR /&gt;20021030&lt;BR /&gt;;</description>
      <pubDate>Sun, 26 Aug 2018 03:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489861#M127999</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-26T03:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the week number of a month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489888#M128017</link>
      <description>&lt;P&gt;That can be fixed.&amp;nbsp; You need to treat the date as a valid SAS date, not as an eight-digit number.&amp;nbsp; Unfortunately, it gets a little complex, so I'll break it out as two separate statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;true_sasdate = input(put(datevar, z8.), yymmdd8.);&lt;/P&gt;
&lt;P&gt;weeknum = ceil( day(true_sasdate) / 7);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Aug 2018 11:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489888#M128017</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-26T11:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the week number of a month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489968#M128063</link>
      <description>Hi, Astounding&lt;BR /&gt;It works!&lt;BR /&gt;Yes, I have to transform the date to a valid SAS date first.&lt;BR /&gt;Thank you very much.</description>
      <pubDate>Mon, 27 Aug 2018 04:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-week-number-of-a-month/m-p/489968#M128063</guid>
      <dc:creator>AndyTeng</dc:creator>
      <dc:date>2018-08-27T04:44:40Z</dc:date>
    </item>
  </channel>
</rss>

