<?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: Look-Ahead and Look-Back in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563953#M33910</link>
    <description>&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;Also, i'm NOT a sas coder. Simple data steps are my speed&lt;/EM&gt;.&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;EG point&amp;amp;click doesn't create a lot of SAS data step code so I'd say using SAS data step in a code window is coding.&lt;/P&gt;
&lt;P&gt;Having said that: If you can't use the ETS tasks then you still could use the query builder.&lt;/P&gt;
&lt;P&gt;With the query builder:&lt;/P&gt;
&lt;P&gt;1. left join your source table with itself&lt;/P&gt;
&lt;P&gt;2. select all variables from the left table&lt;/P&gt;
&lt;P&gt;3. create a computed column using avg_price from your right table with a formula like: max(t2.avg_price)&lt;/P&gt;
&lt;P&gt;4. Tick box "select distinct rows only"&lt;/P&gt;
&lt;P&gt;5. the join condition needs to be something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;t1.item=t2.item AND t2.week between t1.week-12 and t1.week&amp;nbsp; &amp;nbsp; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; ... or depending how you define the look-back period: t2.week between t1.week-13 and t1.week-1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jun 2019 03:49:57 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-06-06T03:49:57Z</dc:date>
    <item>
      <title>Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563890#M33902</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set of product sales and pricing that is sorted by product by week. I want to create a data step that "looks back" 12 weeks from the current week and selects the maximum price for that product. The 12 week "look back" period would then move forward as the data step progresses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, i'm NOT a sas coder. Simple data steps are my speed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 21:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563890#M33902</guid>
      <dc:creator>JeffM</dc:creator>
      <dc:date>2019-06-05T21:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563892#M33903</link>
      <description>Do you have a license for SAS ETS? If so, PROC EXPAND can do this quite easily. You can check what products you have by using the following code and checking the log:&lt;BR /&gt;&lt;BR /&gt;proc product_status;run;</description>
      <pubDate>Wed, 05 Jun 2019 21:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563892#M33903</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-05T21:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563893#M33904</link>
      <description>I use SAS-EG and I am not familiar with SAS language. I want to create a process in EG and plug a data step in the middle.</description>
      <pubDate>Wed, 05 Jun 2019 21:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563893#M33904</guid>
      <dc:creator>JeffM</dc:creator>
      <dc:date>2019-06-05T21:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563895#M33905</link>
      <description>There's a set of time series procedures in EG under tasks, did you try there first? If you have SAS/ETS these tasks will do what you need.</description>
      <pubDate>Wed, 05 Jun 2019 21:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563895#M33905</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-05T21:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563896#M33906</link>
      <description>And I'm going to move this post to the EG section, since you're not programming.</description>
      <pubDate>Wed, 05 Jun 2019 21:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563896#M33906</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-05T21:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563953#M33910</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;Also, i'm NOT a sas coder. Simple data steps are my speed&lt;/EM&gt;.&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;EG point&amp;amp;click doesn't create a lot of SAS data step code so I'd say using SAS data step in a code window is coding.&lt;/P&gt;
&lt;P&gt;Having said that: If you can't use the ETS tasks then you still could use the query builder.&lt;/P&gt;
&lt;P&gt;With the query builder:&lt;/P&gt;
&lt;P&gt;1. left join your source table with itself&lt;/P&gt;
&lt;P&gt;2. select all variables from the left table&lt;/P&gt;
&lt;P&gt;3. create a computed column using avg_price from your right table with a formula like: max(t2.avg_price)&lt;/P&gt;
&lt;P&gt;4. Tick box "select distinct rows only"&lt;/P&gt;
&lt;P&gt;5. the join condition needs to be something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;t1.item=t2.item AND t2.week between t1.week-12 and t1.week&amp;nbsp; &amp;nbsp; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; ... or depending how you define the look-back period: t2.week between t1.week-13 and t1.week-1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 03:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/563953#M33910</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-06-06T03:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564051#M33913</link>
      <description>&lt;P&gt;I actually AM programming....just a data step.&amp;nbsp; I am not writing the whole thing in code.&amp;nbsp; The rest of the process will be all queries.&amp;nbsp; I have extensive experience with VBA so I understand what's going on.&amp;nbsp; I just don't know the SAS language.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 12:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564051#M33913</guid>
      <dc:creator>JeffM</dc:creator>
      <dc:date>2019-06-06T12:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564052#M33914</link>
      <description>&lt;P&gt;You are correct.&amp;nbsp; I am creating a process in EG with queries BUT I want to plug a data step in the middle to do this one thing.&amp;nbsp; The issue with your reply is that the source data file is large so the joins will grind it to a halt.&amp;nbsp; I also need the 12 week window to move...like the Price Is Right guess the price game if you've seen it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 12:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564052#M33914</guid>
      <dc:creator>JeffM</dc:creator>
      <dc:date>2019-06-06T12:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564088#M33915</link>
      <description>&lt;P&gt;Here could give you some hint ,if you know SQL somewhat .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
 select *,(select max(air) from sashelp.air
where date between intnx('week',a.date,-12,'s') and a.date ) as max_12w_back 
  from sashelp.air as a;
quit&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jun 2019 13:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564088#M33915</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-06-06T13:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564089#M33916</link>
      <description>&lt;P&gt;Thanks, but this thread got moved to the wrong spot.&amp;nbsp; Imagine a spreadsheet with 1B records.&amp;nbsp; I need to copy a formula down that calculates a rolling 12 week max.&amp;nbsp; I am looking for tips in a data step on how to do this.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 13:47:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564089#M33916</guid>
      <dc:creator>JeffM</dc:creator>
      <dc:date>2019-06-06T13:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564137#M33918</link>
      <description>Not the wrong spot, you're using EG and there are several methods in EG to do this without using a data step, via a task or query builder. &lt;BR /&gt;&lt;BR /&gt;Here are several variations are here on how to do this and you've received several options above. If one doesn't work, please post back and explain how it's not working. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2016/01/27/moving-average-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2016/01/27/moving-average-in-sas.html&lt;/A&gt;</description>
      <pubDate>Thu, 06 Jun 2019 14:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564137#M33918</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-06T14:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Look-Ahead and Look-Back</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564319#M33926</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276850"&gt;@JeffM&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does "large" mean for you? Tell us more about your data.&lt;/P&gt;
&lt;P&gt;The SQL I've proposed will do a rolling sum over a 12 week window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The required data step logic for a rolling sum is most likely no more beginner level. Coding for performance normally adds additional complexity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You tell us that you are NO coder which at least to me sends the clear message that you're going to reject any data step code above beginner level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 21:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Look-Ahead-and-Look-Back/m-p/564319#M33926</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-06-06T21:43:01Z</dc:date>
    </item>
  </channel>
</rss>

