<?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: Convert numeric week of the year to date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394861#M66433</link>
    <description>&lt;P&gt;There are three SAS supplied informats that will do this if the input string looks like yyyyWww where the W is exactly that, the letter W and the ww are the week number. The informats are WeekU WeekV and WeekW which have different details of first day of the week and where the first week of the year starts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x = '2013W34';
   d1 = input(x,weeku7.);
   d2 = input(x,weekv7.);
   d3 = input(x,weekw7.);
   put d1= date9. d2= date9. d3= date9.;
run;&lt;/PRE&gt;
&lt;P&gt;So if you can get the value into that format you have three choices but you should read the details on the informats to see which matches your "week" definition best.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2017 19:28:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-09-11T19:28:08Z</dc:date>
    <item>
      <title>Convert numeric week of the year to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394836#M66426</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have the following problem:&lt;/P&gt;&lt;P&gt;My data set consists of a variable,which consists of a numeric expression 'year plus week of the year' e.g. 201124 or 201334.&lt;/P&gt;&lt;P&gt;How can I convert this expression into a date variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 18:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394836#M66426</guid>
      <dc:creator>Dynamike</dc:creator>
      <dc:date>2017-09-11T18:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric week of the year to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394842#M66429</link>
      <description>&lt;P&gt;What is the type and format for this variable?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 18:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394842#M66429</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-11T18:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric week of the year to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394861#M66433</link>
      <description>&lt;P&gt;There are three SAS supplied informats that will do this if the input string looks like yyyyWww where the W is exactly that, the letter W and the ww are the week number. The informats are WeekU WeekV and WeekW which have different details of first day of the week and where the first week of the year starts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x = '2013W34';
   d1 = input(x,weeku7.);
   d2 = input(x,weekv7.);
   d3 = input(x,weekw7.);
   put d1= date9. d2= date9. d3= date9.;
run;&lt;/PRE&gt;
&lt;P&gt;So if you can get the value into that format you have three choices but you should read the details on the informats to see which matches your "week" definition best.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 19:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394861#M66433</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-11T19:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric week of the year to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394986#M66439</link>
      <description>&lt;P&gt;Hi ballardw!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;I worked it out like this (i think it is not the easiest way, but it works (almost)):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Test;&lt;BR /&gt;set imp.SHT;&lt;BR /&gt;year=Substr(left(x),1,4);&lt;BR /&gt;week=Substr(left(x),5,2);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Proc SQL;&lt;BR /&gt;Create Table Test2 as&lt;BR /&gt;Select distinct *, input(year,$4.) || "W" || input(week,$2.) as x2&lt;BR /&gt;from test&lt;BR /&gt;group by Pseudonym;&lt;BR /&gt;Quit;&lt;BR /&gt;&lt;BR /&gt;data Test3;&lt;BR /&gt;Set Test2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; d1 = input(x2,weeku7.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; d2 = input(x2,weekv7.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; d3 = input(x2,weekw7.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; put d1= date9. d2= date9. d3= date9.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now i can see in the log file:&lt;/P&gt;&lt;P&gt;e.g. for 2011W39&lt;/P&gt;&lt;P&gt;d1=25SEP2011 d2=26SEP2011 d3=26SEP2011 (which should be the right expression)&lt;/P&gt;&lt;P&gt;But in the data set it is still shown as&lt;/P&gt;&lt;P&gt;d1=18895 d2=18896 d3=18896&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What could be the reason for this?&lt;/P&gt;&lt;P&gt;Right expression in the log file, but still numeric expression in the data set?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 05:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394986#M66439</guid>
      <dc:creator>Dynamike</dc:creator>
      <dc:date>2017-09-12T05:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric week of the year to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394988#M66440</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/164229"&gt;@Dynamike&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now i can see in the log file:&lt;/P&gt;
&lt;P&gt;e.g. for 2011W39&lt;/P&gt;
&lt;P&gt;d1=25SEP2011 d2=26SEP2011 d3=26SEP2011 (which should be the right expression)&lt;/P&gt;
&lt;P&gt;But in the data set it is still shown as&lt;/P&gt;
&lt;P&gt;d1=18895 d2=18896 d3=18896&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What could be the reason for this?&lt;/P&gt;
&lt;P&gt;Right expression in the log file, but still numeric expression in the data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you don't attach a format to a number then SAS will use BEST12 format display it most situations.&lt;/P&gt;
&lt;P&gt;If you want your date values to print using DATE9 format by default then add a FORMAT statement to your data step to permanently attach the format.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 05:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394988#M66440</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-12T05:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Convert numeric week of the year to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394990#M66441</link>
      <description>&lt;P&gt;Ah sorry.&lt;/P&gt;&lt;P&gt;It works with "format d1=date9." instead of "put d1=date9."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice day!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 05:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-numeric-week-of-the-year-to-date/m-p/394990#M66441</guid>
      <dc:creator>Dynamike</dc:creator>
      <dc:date>2017-09-12T05:43:43Z</dc:date>
    </item>
  </channel>
</rss>

