<?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: Efficient code in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545426#M8023</link>
    <description>&lt;P&gt;SAS provides date interval functions for handling date operations without having to refer to date values internal representation. For shifting dates, the function is INTNX :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data frequencydate; 
format weekStart yymmdd10.;
start_date = '01Nov2018'd;
do i = 0 to 21;
	weekStart = intnx("week", start_date, i, "sameday");
	output;
end;
drop start_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 23 Mar 2019 04:32:59 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2019-03-23T04:32:59Z</dc:date>
    <item>
      <title>Efficient code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545394#M8018</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS. Can you help me with a more efficient code rather than the one I used below?&lt;/P&gt;&lt;P&gt;Dates for weekstart are increments of 7 days starting 01Nov2018.&lt;/P&gt;&lt;P&gt;Also, I do not want the code to have an end or 'until' date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data frequencydate;&amp;nbsp;&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>Sat, 23 Mar 2019 00:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545394#M8018</guid>
      <dc:creator>Maiio</dc:creator>
      <dc:date>2019-03-23T00:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545396#M8019</link>
      <description>&lt;P&gt;Here's a quick way. SAS dates are stored in number of days, so you can use basic arithmetic here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data frequencydate; 
set frequency;
format weekStart date9.;

start_date = '01Nov2018'd;
weekStart = start_date + week*7;

drop start_date;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120158"&gt;@Maiio&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm new to SAS. Can you help me with a more efficient code rather than the one I used below?&lt;/P&gt;
&lt;P&gt;Dates for weekstart are increments of 7 days starting 01Nov2018.&lt;/P&gt;
&lt;P&gt;Also, I do not want the code to have an end or 'until' date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data frequencydate;&amp;nbsp;&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;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Mar 2019 00:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545396#M8019</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-23T00:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545402#M8020</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data frequencydate; 
length myi 8.;
format weekStart date9.;
	start_date = '01Nov2018'd;
	do i = 0 to 52;
		myi=i;
		weekStart = start_date + myi*7;
		output;
	end;
drop start_date myi;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Mar 2019 00:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545402#M8020</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-03-23T00:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545426#M8023</link>
      <description>&lt;P&gt;SAS provides date interval functions for handling date operations without having to refer to date values internal representation. For shifting dates, the function is INTNX :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data frequencydate; 
format weekStart yymmdd10.;
start_date = '01Nov2018'd;
do i = 0 to 21;
	weekStart = intnx("week", start_date, i, "sameday");
	output;
end;
drop start_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Mar 2019 04:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-code/m-p/545426#M8023</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-23T04:32:59Z</dc:date>
    </item>
  </channel>
</rss>

