<?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: How to pull records before and after based on an event? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498831#M32076</link>
    <description>&lt;P&gt;You need to do what's called a SQL self join here, at least that's the easiest method. You can do it via the GUI but it's a bit of a pain. Are you looking for a coding solution or a GUI solution?&lt;BR /&gt;&lt;BR /&gt;Can you provide sample data via text - especially if you want code -&amp;nbsp; otherwise it's easier to just tell you the approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions on generating data is here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can't provide your real data, make some fake data that looks close enough and has a few different scenarios, ie only before, only after, multiple purchases within the two month period, multiple vehicles within the two month period and no purchases before and after.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/227523"&gt;@mikefiorelli&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Final product.JPG" style="width: 540px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23515iF3352813D4FA3E3D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Final product.JPG" alt="Final product.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;hi so i am using SAS ENTERPRISE GUIDE. I am trying to pull claims data for my customers based on an event. the event is the purchase of a car. so i am trying to pull all customers who purchases a car in 2017 and pull all their purchases that happened 2 months before and after the original purchase of the car. i want to exclude anything that happened over 2 months pre and post.&lt;/P&gt;
&lt;P&gt;table 1 pictured here is the original table that has all my customers, table 2 is the final product that i need to get to. i also like to create a column in my table 2 saying what was the original purchase (in this case it's the car)&lt;/P&gt;
&lt;P&gt;any help is appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can I attach my project? i won't let me do that&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23516iB59D4494C33F5113/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS.JPG" alt="SAS.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Sep 2018 19:25:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-09-25T19:25:17Z</dc:date>
    <item>
      <title>How to pull records before and after based on an event?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498793#M32066</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Final product.JPG" style="width: 540px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23515iF3352813D4FA3E3D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Final product.JPG" alt="Final product.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;hi so i am using SAS ENTERPRISE GUIDE. I am trying to pull claims data for my customers based on an event. the event is the purchase of a car. so i am trying to pull all customers who purchases a car in 2017 and pull all their purchases that happened 2 months before and after the original purchase of the car. i want to exclude anything that happened over 2 months pre and post.&lt;/P&gt;&lt;P&gt;table 1 pictured here is the original table that has all my customers, table 2 is the final product that i need to get to. i also like to create a column in my table 2 saying what was the original purchase (in this case it's the car)&lt;/P&gt;&lt;P&gt;any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can I attach my project? i won't let me do that&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23516iB59D4494C33F5113/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS.JPG" alt="SAS.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 18:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498793#M32066</guid>
      <dc:creator>mikefiorelli</dc:creator>
      <dc:date>2018-09-25T18:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull records before and after based on an event?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498815#M32073</link>
      <description>&lt;P&gt;Are all your date variables legitimate SAS dates?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want to base the data on the purchase date.&amp;nbsp; But your data doesn't contain a purchase date.&amp;nbsp; Can you clarify that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a purchase was made on February 28, what is the the two-month cutoff?&amp;nbsp; April 28?&amp;nbsp; April 30?&amp;nbsp; Would a 60-day window be preferable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a customer purchased two cars a month apart, all the purchases in between should be extracted.&amp;nbsp; (And more than that as well.)&amp;nbsp; But for the purchases that fall into the window between the two car purchases, should they appear once in the final data set or twice?&amp;nbsp; How will you determine which other purchases are associated with which car purchase?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 18:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498815#M32073</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-25T18:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull records before and after based on an event?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498831#M32076</link>
      <description>&lt;P&gt;You need to do what's called a SQL self join here, at least that's the easiest method. You can do it via the GUI but it's a bit of a pain. Are you looking for a coding solution or a GUI solution?&lt;BR /&gt;&lt;BR /&gt;Can you provide sample data via text - especially if you want code -&amp;nbsp; otherwise it's easier to just tell you the approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions on generating data is here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can't provide your real data, make some fake data that looks close enough and has a few different scenarios, ie only before, only after, multiple purchases within the two month period, multiple vehicles within the two month period and no purchases before and after.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/227523"&gt;@mikefiorelli&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Final product.JPG" style="width: 540px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23515iF3352813D4FA3E3D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Final product.JPG" alt="Final product.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;hi so i am using SAS ENTERPRISE GUIDE. I am trying to pull claims data for my customers based on an event. the event is the purchase of a car. so i am trying to pull all customers who purchases a car in 2017 and pull all their purchases that happened 2 months before and after the original purchase of the car. i want to exclude anything that happened over 2 months pre and post.&lt;/P&gt;
&lt;P&gt;table 1 pictured here is the original table that has all my customers, table 2 is the final product that i need to get to. i also like to create a column in my table 2 saying what was the original purchase (in this case it's the car)&lt;/P&gt;
&lt;P&gt;any help is appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can I attach my project? i won't let me do that&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23516iB59D4494C33F5113/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS.JPG" alt="SAS.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 19:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498831#M32076</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-25T19:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull records before and after based on an event?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498905#M32079</link>
      <description>&lt;P&gt;Service start date would be my purchase date. 60 days pre and 60 days post are fair enough. i appreciate the help&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 01:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498905#M32079</guid>
      <dc:creator>mikefiorelli</dc:creator>
      <dc:date>2018-09-26T01:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull records before and after based on an event?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498910#M32081</link>
      <description>&lt;P&gt;this is my sample data. the table has million of customers.my service start date for the car is the main date that I want to use to capture all claims 2 months pre and 2 months post. 60 days pre and post is fair enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;customer service start date service end date type of purchase&lt;BR /&gt;A 1/1/2017 1/5/2017 Car&lt;BR /&gt;A 11/21/2016 12/1/2016 Truck&lt;BR /&gt;A 1/8/2017 1/23/2017 Plane&lt;BR /&gt;A 6/4/2016 6/6/2016 boat&lt;BR /&gt;B 1/6/2017 1/9/2017 Car&lt;BR /&gt;B 11/11/2016 12/4/2016 Truck&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I created this process below where i imported my table first, i created a query(querybuilder1) to pull the car purchases, than query 2 pull all claims except the car. query 3 combine both tables(i did a join on customer )and filtered within the date that falls 2 months pre and post.i used that function on the service start date from my table 2: -60 &amp;lt; t1.'service start date'n - t2.'service start date'n &amp;lt; 60. the final result(query3) combine both tables but it didn't stack the results, it added them next to each other(not what i wanted, see second picture)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Main.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23525i2166ABF4C7BC9EFF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Main.JPG" alt="Main.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="final result.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23526i39E4DA74D872FC27/image-size/large?v=v2&amp;amp;px=999" role="button" title="final result.JPG" alt="final result.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 01:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498910#M32081</guid>
      <dc:creator>mikefiorelli</dc:creator>
      <dc:date>2018-09-26T01:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull records before and after based on an event?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498932#M32082</link>
      <description>For appending records, try using a UNION within Query Builder (not sure if that's possible) or use an APPEND procedure. Note that the names must be the same to 'stack' your data.</description>
      <pubDate>Wed, 26 Sep 2018 03:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-pull-records-before-and-after-based-on-an-event/m-p/498932#M32082</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-26T03:02:04Z</dc:date>
    </item>
  </channel>
</rss>

