<?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: dates conversion in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108978#M30362</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can live with a slightly different format for week_t one solution might be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format thedate date.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format week_t ddmmyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do thedate='01jan2011'd to '31dec2011'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week=put(thedate+7,weekw11.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week_t=intnx('week.2',thedate,0,'end');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 27 Oct 2012 19:05:19 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-10-27T19:05:19Z</dc:date>
    <item>
      <title>dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108973#M30357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a date in my dataset in format DD/MM/YYYY and i have to convert it in two different variables:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;the first is the variable WEEK and has to be YYYYWW where WW is the number of the week of the year YYYY&lt;/LI&gt;&lt;LI&gt;the second is WEEK_T and has to be in format DD/MM/YYYY where the day must be the sunday of the corresponding week.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll leave you an example:&lt;/P&gt;&lt;P&gt;DATE: 08/07/2011 (it's a friday)&lt;/P&gt;&lt;P&gt;WEEK: 201127&lt;/P&gt;&lt;P&gt;WEEK_T: 10/07/2011 (it's the sunday of the week #27 of 2011)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your help &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Oct 2012 15:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108973#M30357</guid>
      <dc:creator>Way2go</dc:creator>
      <dc:date>2012-10-27T15:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108974#M30358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;I think week_t should be 3/7/2011 rather than 10.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;SPAN style="color: #000000;"&gt;date=&lt;/SPAN&gt;&lt;STRONG&gt;'08Jul2011'd&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;week_date=week(date);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;week_formatted=year(date)*&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;100&lt;/STRONG&gt;&lt;/SPAN&gt;+week_date;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;sunday=intnx(&lt;SPAN style="color: #942193;"&gt;'week'&lt;/SPAN&gt;, date, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;, &lt;SPAN style="color: #942193;"&gt;'beginning'&lt;/SPAN&gt;);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;SPAN style="color: #000000;"&gt;test=&lt;/SPAN&gt;&lt;STRONG&gt;'03Jul2011'd&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;test_week=week(test);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;format&lt;/SPAN&gt; sunday test date &lt;SPAN style="color: #009193;"&gt;date9.&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Oct 2012 16:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108974#M30358</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-10-27T16:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108975#M30359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to define week first.&amp;nbsp; Does it begin with Jan1st?&amp;nbsp; Is the first week 0 or 1 or dependent upon whether the first week began during the previous year?&amp;nbsp; Does each week begin on a particular day of the week?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Given your example, I would guess that you consider Monday to be the first day of the week and that you consider the first week to be numbered 0 or something else.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Oct 2012 16:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108975#M30359</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-10-27T16:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108976#M30360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, right. I have made a bad formulation of the problem. I don't have a single date, but a variable date (DD/MM/YYYY), week and week_t.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Imagine the dataset made this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WEEK&amp;nbsp;&amp;nbsp;&amp;nbsp; WEEK_T&lt;/P&gt;&lt;P&gt;08/07/2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;16/07/2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc etc for about 8 millions observation (so i can't put this line &lt;SPAN style="font-size: 10px; font-family: 'Courier New'; background-color: #ffffff; color: #000000;"&gt;date=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10px; font-family: 'Courier New'; color: #009193; background-color: #ffffff;"&gt;&lt;STRONG&gt;'08Jul2011'd&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10px; font-family: 'Courier New'; background-color: #ffffff; color: #000000;"&gt;; &lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;for every date in my dataset&lt;/SPAN&gt; &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;). &lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;How can i find the values for week and week_t?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the value of week_t in my example should be 10/07/2011 because the week starts on monday.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Oct 2012 16:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108976#M30360</guid>
      <dc:creator>Way2go</dc:creator>
      <dc:date>2012-10-27T16:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108977#M30361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Each week starts on monday and finishes on sunday.&lt;/P&gt;&lt;P&gt;The week #1 of 2011 is the one that ends on the first sunday of january 2011, so i don't have a week 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope I've made this more clear to you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Oct 2012 16:37:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108977#M30361</guid>
      <dc:creator>Way2go</dc:creator>
      <dc:date>2012-10-27T16:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108978#M30362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can live with a slightly different format for week_t one solution might be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format thedate date.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format week_t ddmmyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do thedate='01jan2011'd to '31dec2011'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week=put(thedate+7,weekw11.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week_t=intnx('week.2',thedate,0,'end');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Oct 2012 19:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108978#M30362</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-10-27T19:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108979#M30363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok...&lt;/P&gt;&lt;P&gt;Here's the compilation of Arthur's and Reeza variants with additional comments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data ResultSet;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set YourSourceDataSetWith8MillionRows;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* get the sunday of the week, which starts on monday. The number of the weeks in SAS are determined according to ISO standart */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; week_t = intnx('week.2', date, 0, 'e');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* as there is no format which won't print 'W' letter in the date format of the YYYYWW kind you can use this, but beware! use comparison with 'week' accurately */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; week = year(week_t) * 100 + week (week_t) - 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format week_t DDMMYY10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format week 6.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... well, at least it fits to your source requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for this 'compilation' of already solved problem, but I think this thread must be marked as 'Answered' and was sure it's due to problems with interpretation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 11:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108979#M30363</guid>
      <dc:creator>ghastly_kitten</dc:creator>
      <dc:date>2012-10-29T11:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108980#M30364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;EM&gt;Sorry for this 'compilation' of already solved problem, but I think this thread must be marked as 'Answered' and was sure it's due to problems with interpretation.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;I saw all the answers but I haven't had the occasion to try them yet. As soon as I try them in SAS I won't hesitate to mark it answered&lt;EM&gt; &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 11:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dates-conversion/m-p/108980#M30364</guid>
      <dc:creator>Way2go</dc:creator>
      <dc:date>2012-10-29T11:19:21Z</dc:date>
    </item>
  </channel>
</rss>

