<?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: Date to week in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804564#M316848</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;I imported this date from a CSV file. The original format of data was&amp;nbsp;yymmdd10. which I changed it to&amp;nbsp;&lt;SPAN&gt;DATE9.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Mar 2022 16:37:36 GMT</pubDate>
    <dc:creator>Bright</dc:creator>
    <dc:date>2022-03-28T16:37:36Z</dc:date>
    <item>
      <title>Date to week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804548#M316841</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a "date" like&amp;nbsp;2015-02-22 (format is DATE9.) and I want to have the week number of this date. In this example, the output should be 15W08 (format is&amp;nbsp;WEEKW5.). I am using function week(date) but the output for this example is 60W01, which is incorrect. Any idea of what is going wrong?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804548#M316841</guid>
      <dc:creator>Bright</dc:creator>
      <dc:date>2022-03-28T16:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Date to week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804558#M316843</link>
      <description>&lt;P&gt;Usually when dates get converted to 1960 is is because you are trying to interpret a DATE value (number of days) as a DATETIME value (number of seconds).&amp;nbsp; Since there are 86,400 seconds in a day (24*60*60) and only 365 days in a year that means that any reasonable date value will look like some early morning time on 01JAN1960&amp;nbsp;when treated as a datetime.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804558#M316843</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-28T16:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Date to week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804561#M316846</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Thanks for the explanation. So what can I do to resolve this issue? Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:30:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804561#M316846</guid>
      <dc:creator>Bright</dc:creator>
      <dc:date>2022-03-28T16:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Date to week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804563#M316847</link>
      <description>&lt;P&gt;Show how you created the variable that you applied the WEEKW format to.&lt;/P&gt;
&lt;P&gt;If the value is a DATE value then it should work.&amp;nbsp; But if you started with a date value and then used the DATEPART() function on it then you will get 01JAN1960 since the DATEPART() function is essentially just dividing the value by 86,400.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804563#M316847</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-28T16:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date to week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804564#M316848</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;I imported this date from a CSV file. The original format of data was&amp;nbsp;yymmdd10. which I changed it to&amp;nbsp;&lt;SPAN&gt;DATE9.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804564#M316848</guid>
      <dc:creator>Bright</dc:creator>
      <dc:date>2022-03-28T16:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date to week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804565#M316849</link>
      <description>&lt;P&gt;Something else has happened then.&amp;nbsp; If by import you mean PROC IMPORT then it should have read the value as a date.&lt;/P&gt;
&lt;P&gt;You can test by looking that value with different formats.&lt;/P&gt;
&lt;P&gt;So if your dataset is named HAVE and the variable is named DATE then run a step like this to look at the values of DATE in the first 5 observations.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have (obs=5);
  put date=  +1 date comma10. +1 date yymmdd10.  +1 date weekw5. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804565#M316849</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-28T16:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Date to week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804571#M316850</link>
      <description>&lt;P&gt;The WEEK format is meant to be applied to a SAS date value. If you feed it the result of the WEEK() function (which lies in the range 0-53), the format will return a year/week early in 1960. Apply the format directly to the date, without using the WEEK() function.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 17:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804571#M316850</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-28T17:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Date to week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804616#M316870</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;I have a "date" like 2015-02-22 (format is DATE9.)&lt;/EM&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No clue what this means. A SAS date with format DATE9. will appear as 22FEB2015. It will never appear as 2015-02-22 if it has that format. Perhaps you have assigned a date value like this&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;mydate = 2015-02-22;
format mydate date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which would be 100% wrong, and gives the wrong week number you showed us. But I'm guessing. Explain your situation with much more detail. SHOW US your SAS data set, and SHOW US the code you used to create this SAS date. (Just to be clear, we need you to SHOW US the two things mentioned, not one or the other)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 20:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-to-week/m-p/804616#M316870</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-28T20:13:26Z</dc:date>
    </item>
  </channel>
</rss>

