<?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 how can I select next 90 days observation for an id with particular product ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-select-next-90-days-observation-for-an-id-with/m-p/629285#M186065</link>
    <description>&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Hi, I can't find a way for a particular problem at my work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;In the below dataset I have ids , date on which they brought the product and another column for what product they bought.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;I want &lt;/SPAN&gt;&lt;STRONG&gt;all products&lt;/STRONG&gt;&lt;SPAN style="font-weight: 400;"&gt; used by &lt;/SPAN&gt;&lt;STRONG&gt;each id&lt;/STRONG&gt;&lt;SPAN style="font-weight: 400;"&gt; in the &lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;next 90 days&lt;/I&gt;&lt;/STRONG&gt; &lt;SPAN style="font-weight: 400;"&gt;after buying product X.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;id&amp;nbsp; &amp;nbsp; date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 01JAN2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 20FEB2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 28MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;02 &amp;nbsp; 10JUN2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;02 &amp;nbsp; 02OCT2019&amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 05JAN2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 22FEB2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 15MAR2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 29MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 13APR2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; D&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 15AUG2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; E&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Final Output:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;id&amp;nbsp; &amp;nbsp; date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 20FEB2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 28MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;02 &amp;nbsp; 10JUN2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 15MAR2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 29MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 13APR2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; D&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Mar 2020 21:13:34 GMT</pubDate>
    <dc:creator>kksas</dc:creator>
    <dc:date>2020-03-03T21:13:34Z</dc:date>
    <item>
      <title>how can I select next 90 days observation for an id with particular product ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-select-next-90-days-observation-for-an-id-with/m-p/629285#M186065</link>
      <description>&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Hi, I can't find a way for a particular problem at my work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;In the below dataset I have ids , date on which they brought the product and another column for what product they bought.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;I want &lt;/SPAN&gt;&lt;STRONG&gt;all products&lt;/STRONG&gt;&lt;SPAN style="font-weight: 400;"&gt; used by &lt;/SPAN&gt;&lt;STRONG&gt;each id&lt;/STRONG&gt;&lt;SPAN style="font-weight: 400;"&gt; in the &lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;next 90 days&lt;/I&gt;&lt;/STRONG&gt; &lt;SPAN style="font-weight: 400;"&gt;after buying product X.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;id&amp;nbsp; &amp;nbsp; date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 01JAN2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 20FEB2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 28MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;02 &amp;nbsp; 10JUN2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;02 &amp;nbsp; 02OCT2019&amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 05JAN2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 22FEB2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 15MAR2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 29MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 13APR2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; D&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 15AUG2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; E&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;Final Output:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;id&amp;nbsp; &amp;nbsp; date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 20FEB2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;01 &amp;nbsp; 28MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;02 &amp;nbsp; 10JUN2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 15MAR2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 29MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: 400;"&gt;03 &amp;nbsp; 13APR2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; D&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 21:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-select-next-90-days-observation-for-an-id-with/m-p/629285#M186065</guid>
      <dc:creator>kksas</dc:creator>
      <dc:date>2020-03-03T21:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: how can I select next 90 days observation for an id with particular product ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-select-next-90-days-observation-for-an-id-with/m-p/629290#M186068</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    merge have(where=(prd='X') rename=(date=xdate)) have(where=(prd^='X'));
    by id;
    if date-xdate&amp;lt;=90 then output;
    drop xdate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assumes data set is sorted by ID.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 21:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-select-next-90-days-observation-for-an-id-with/m-p/629290#M186068</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-03T21:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: how can I select next 90 days observation for an id with particular product ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-can-I-select-next-90-days-observation-for-an-id-with/m-p/629294#M186071</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
 input id    date   :date9.              PRD $;
 format date date9.;
 cards;

01   01JAN2019       A

01   20FEB2019       X

01   28MAR2019      B

02   10JUN2019       X

02   02OCT2019      A

03   05JAN2019        A

03   22FEB2019        B

03   15MAR2019       X

03   29MAR2019      C

03   13APR2019       D

03   15AUG2019       E
;

data want;
 set have;
 by id;
 retain _d;
 if first.id then call missing(_d);
 if prd='X' then do; _d=date;output;end;
 else if _d then if _d&amp;lt;=date&amp;lt;=intnx('day',_d,90) then output;
 drop _d;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;/*or*/&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
 set have;
 by id;
 retain _d;
 if first.id then call missing(_d);
 if prd='X' then  _d=date;
 if _d then if _d&amp;lt;=date&amp;lt;=intnx('day',_d,90) then output;
 drop _d;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 22:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-can-I-select-next-90-days-observation-for-an-id-with/m-p/629294#M186071</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-03T22:02:40Z</dc:date>
    </item>
  </channel>
</rss>

