<?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 Efficient code in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545393#M8017</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS, and I know for sure there's an easier way to write this code.&lt;/P&gt;&lt;P&gt;I have a week variable (week) with integer values and I need to create a new variable (weekstart) where I give each week number a date. Dates are 7 day increments from the 1st date (01Nov2018), which is week 0.&lt;/P&gt;&lt;P&gt;I'm pretty sure there's a straightforward answer. Can someone help? Also, week and weekstart should keep going (i.e. there is no end date).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data frequencydate;&lt;BR /&gt;set frequency;&lt;BR /&gt;format weekstart date9.;&lt;BR /&gt;if week=0 then weekstart='01Nov2018'd;&lt;BR /&gt;else if week= 1 then weekstart='08Nov2018'd;&lt;BR /&gt;else if week= 2 then weekstart='15Nov2018'd;&lt;BR /&gt;else if week= 3 then weekstart='22Nov2018'd;&lt;BR /&gt;else if week= 4 then weekstart='29Nov2018'd;&lt;BR /&gt;else if week= 5 then weekstart='06Dec2018'd;&lt;BR /&gt;else if week= 6 then weekstart='13Dec2018'd;&lt;BR /&gt;else if week= 7 then weekstart='20Dec2018'd;&lt;BR /&gt;else if week= 8 then weekstart='27Dec2018'd;&lt;BR /&gt;else if week= 9 then weekstart='03Jan2019'd;&lt;BR /&gt;else if week= 10 then weekstart='10Jan2019'd;&lt;BR /&gt;else if week= 11 then weekstart='17Jan2019'd;&lt;BR /&gt;else if week= 12 then weekstart='24Jan2019'd;&lt;BR /&gt;else if week= 13 then weekstart='31Jan2019'd;&lt;BR /&gt;else if week= 14 then weekstart='07Feb2019'd;&lt;BR /&gt;else if week= 15 then weekstart='14Feb2019'd;&lt;BR /&gt;else if week= 16 then weekstart='21Feb2019'd;&lt;BR /&gt;else if week= 17 then weekstart='28Feb2019'd;&lt;BR /&gt;else if week= 18 then weekstart='07Mar2019'd;&lt;BR /&gt;else if week= 19 then weekstart='14Mar2019'd;&lt;BR /&gt;else if week= 20 then weekstart='21Mar2019'd;&lt;BR /&gt;else if week= 21 then weekstart='28Mar2019'd;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2019 23:26:29 GMT</pubDate>
    <dc:creator>Maiio</dc:creator>
    <dc:date>2019-03-22T23:26:29Z</dc:date>
    <item>
      <title>Efficient code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545393#M8017</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS, and I know for sure there's an easier way to write this code.&lt;/P&gt;&lt;P&gt;I have a week variable (week) with integer values and I need to create a new variable (weekstart) where I give each week number a date. Dates are 7 day increments from the 1st date (01Nov2018), which is week 0.&lt;/P&gt;&lt;P&gt;I'm pretty sure there's a straightforward answer. Can someone help? Also, week and weekstart should keep going (i.e. there is no end date).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data frequencydate;&lt;BR /&gt;set frequency;&lt;BR /&gt;format weekstart date9.;&lt;BR /&gt;if week=0 then weekstart='01Nov2018'd;&lt;BR /&gt;else if week= 1 then weekstart='08Nov2018'd;&lt;BR /&gt;else if week= 2 then weekstart='15Nov2018'd;&lt;BR /&gt;else if week= 3 then weekstart='22Nov2018'd;&lt;BR /&gt;else if week= 4 then weekstart='29Nov2018'd;&lt;BR /&gt;else if week= 5 then weekstart='06Dec2018'd;&lt;BR /&gt;else if week= 6 then weekstart='13Dec2018'd;&lt;BR /&gt;else if week= 7 then weekstart='20Dec2018'd;&lt;BR /&gt;else if week= 8 then weekstart='27Dec2018'd;&lt;BR /&gt;else if week= 9 then weekstart='03Jan2019'd;&lt;BR /&gt;else if week= 10 then weekstart='10Jan2019'd;&lt;BR /&gt;else if week= 11 then weekstart='17Jan2019'd;&lt;BR /&gt;else if week= 12 then weekstart='24Jan2019'd;&lt;BR /&gt;else if week= 13 then weekstart='31Jan2019'd;&lt;BR /&gt;else if week= 14 then weekstart='07Feb2019'd;&lt;BR /&gt;else if week= 15 then weekstart='14Feb2019'd;&lt;BR /&gt;else if week= 16 then weekstart='21Feb2019'd;&lt;BR /&gt;else if week= 17 then weekstart='28Feb2019'd;&lt;BR /&gt;else if week= 18 then weekstart='07Mar2019'd;&lt;BR /&gt;else if week= 19 then weekstart='14Mar2019'd;&lt;BR /&gt;else if week= 20 then weekstart='21Mar2019'd;&lt;BR /&gt;else if week= 21 then weekstart='28Mar2019'd;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 23:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545393#M8017</guid>
      <dc:creator>Maiio</dc:creator>
      <dc:date>2019-03-22T23:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545605#M8054</link>
      <description>&lt;P&gt;&lt;SPAN&gt;weekstart='01Nov2018'd + 7 * week;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2019 15:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545605#M8054</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2019-03-24T15:04:20Z</dc:date>
    </item>
  </channel>
</rss>

