<?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 Looking ahead with a Data Step in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Looking-ahead-with-a-Data-Step/m-p/49491#M13442</link>
    <description>I'm hoping someone can help me with the following:&lt;BR /&gt;
&lt;BR /&gt;
The following is my dataset:&lt;BR /&gt;
&lt;BR /&gt;
MKT       RB_FLAG         DATE1       DATE2&lt;BR /&gt;
A            RB                  19SEP       17OCT&lt;BR /&gt;
A            NRB                19SEP        24OCT&lt;BR /&gt;
A            RB                  19SEP        21NOV&lt;BR /&gt;
B            NRB                17OCT       17OCT&lt;BR /&gt;
B            RB                  17OCT        24OCT&lt;BR /&gt;
B            RB                  17OCT        14NOV&lt;BR /&gt;
B            NRB                17OCT        29DEC&lt;BR /&gt;
B            RB                  17OCT        16JAN&lt;BR /&gt;
B            NRB                17OCT        23JAN&lt;BR /&gt;
&lt;BR /&gt;
For each MKT I need to take the first instance when RB_FLAG="RB" and the first instance after where RB_FLAG="NRB" then calculate the difference between DATE1 (for RB) and DATE2 (for NRB).  Also, I'm only interested in the first occurence of RB within a MKT. Ultimately, I'm trying to arrive at the following table:&lt;BR /&gt;
&lt;BR /&gt;
MKT       RB_FLAG         DATE1       DATE2       WEEK_DIFF&lt;BR /&gt;
A            RB                  19SEP        24OCT               5&lt;BR /&gt;
B            RB                  17OCT        19DEC              10&lt;BR /&gt;
&lt;BR /&gt;
I have read some similar posts on "looking ahead" within a datastep but I'm struggling to adapt the suggestions to my problem.&lt;BR /&gt;
&lt;BR /&gt;
Thank you ahead of time for you help on this!&lt;BR /&gt;
Rich</description>
    <pubDate>Sun, 31 Jan 2010 01:22:03 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-01-31T01:22:03Z</dc:date>
    <item>
      <title>Looking ahead with a Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-ahead-with-a-Data-Step/m-p/49491#M13442</link>
      <description>I'm hoping someone can help me with the following:&lt;BR /&gt;
&lt;BR /&gt;
The following is my dataset:&lt;BR /&gt;
&lt;BR /&gt;
MKT       RB_FLAG         DATE1       DATE2&lt;BR /&gt;
A            RB                  19SEP       17OCT&lt;BR /&gt;
A            NRB                19SEP        24OCT&lt;BR /&gt;
A            RB                  19SEP        21NOV&lt;BR /&gt;
B            NRB                17OCT       17OCT&lt;BR /&gt;
B            RB                  17OCT        24OCT&lt;BR /&gt;
B            RB                  17OCT        14NOV&lt;BR /&gt;
B            NRB                17OCT        29DEC&lt;BR /&gt;
B            RB                  17OCT        16JAN&lt;BR /&gt;
B            NRB                17OCT        23JAN&lt;BR /&gt;
&lt;BR /&gt;
For each MKT I need to take the first instance when RB_FLAG="RB" and the first instance after where RB_FLAG="NRB" then calculate the difference between DATE1 (for RB) and DATE2 (for NRB).  Also, I'm only interested in the first occurence of RB within a MKT. Ultimately, I'm trying to arrive at the following table:&lt;BR /&gt;
&lt;BR /&gt;
MKT       RB_FLAG         DATE1       DATE2       WEEK_DIFF&lt;BR /&gt;
A            RB                  19SEP        24OCT               5&lt;BR /&gt;
B            RB                  17OCT        19DEC              10&lt;BR /&gt;
&lt;BR /&gt;
I have read some similar posts on "looking ahead" within a datastep but I'm struggling to adapt the suggestions to my problem.&lt;BR /&gt;
&lt;BR /&gt;
Thank you ahead of time for you help on this!&lt;BR /&gt;
Rich</description>
      <pubDate>Sun, 31 Jan 2010 01:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-ahead-with-a-Data-Step/m-p/49491#M13442</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-01-31T01:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Looking ahead with a Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-ahead-with-a-Data-Step/m-p/49492#M13443</link>
      <description>Investigate using BY GROUP processing within the DATA step and you will want to use RETAIN to track your DATE1 value across DATA step iterations.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Recommended Google advanced search argument for this topic/post:&lt;BR /&gt;
&lt;BR /&gt;
data step by group processing site:sas.com</description>
      <pubDate>Sun, 31 Jan 2010 02:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-ahead-with-a-Data-Step/m-p/49492#M13443</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-01-31T02:46:04Z</dc:date>
    </item>
  </channel>
</rss>

