<?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: Identifying observations for an ID after specific date identified within the same ID. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696306#M212655</link>
    <description>Thank you! This was straightforward and easy to follow. I appreciate all the help. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Tue, 03 Nov 2020 19:39:39 GMT</pubDate>
    <dc:creator>ttbtink</dc:creator>
    <dc:date>2020-11-03T19:39:39Z</dc:date>
    <item>
      <title>Identifying observations for an ID after specific date identified within the same ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696281#M212638</link>
      <description>&lt;P&gt;Sorry if the title is confusing, I have a hard to articulating the problem in a short title. Currently, my data set has a mix of healthcare visits that are primary care(pc) and pain specialists (ps). I am able to identify the FIRST primary care visit for each patient. What I want to do is then identify the next pain specialist visit, in actual time,&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;for that specific patient. I can either delete all pain visits that are before that primary care visit or just create a dummy variable. I do not know how to code for this at all. Below I have the primary care (pc) visit that I already have identified and serves as the starting point (by date) to identify the next pain specialist visit (ps).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;visit&lt;/TD&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;keep&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD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gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;* already identified&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 17:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696281#M212638</guid>
      <dc:creator>ttbtink</dc:creator>
      <dc:date>2020-11-03T17:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations for an ID after specific date identified within the same ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696284#M212641</link>
      <description>&lt;P&gt;I would rather give you the boolean 1 or 0's flag. Feel free to filter at your own convenience-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input ID	visit $	date :mmddyy10.;
format date mmddyy10.;
cards;
1	ps	11/23/2019
1	ps	12/1/2019
1	pc	12/15/2019
1	ps	1/3/2020
2	ps	5/23/2019
2	pc	6/25/2019
2	ps	7/3/2019
3	pc	3/21/2020
3	ps	4/2/2020
;

data want;
 if 0 then set have;
 do flag=0 by 0 until(last.id);
  set have;
  by id;
  if visit='pc' then flag=1;
  output;
 end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 18:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696284#M212641</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-11-03T18:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations for an ID after specific date identified within the same ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696285#M212642</link>
      <description>&lt;P&gt;And the boring traditional text book RETAIN-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
 by id;
 retain flag;
 if first.id then flag=0;
 if   visit='pc' then flag=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Nov 2020 18:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696285#M212642</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-11-03T18:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations for an ID after specific date identified within the same ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696287#M212644</link>
      <description>&lt;P&gt;And this one , dedicating my gratitude to Gurus&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp; for teaching me "&lt;EM&gt;how to master/play with boolean expressions&lt;/EM&gt;" and tolerating my silly questions many times&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;


data have;
input ID	visit $	date :mmddyy10.;
format date mmddyy10.;
cards;
1	ps	11/23/2019
1	ps	12/1/2019
1	pc	12/15/2019
1	ps	1/3/2020
2	ps	5/23/2019
2	pc	6/25/2019
2	ps	7/3/2019
3	pc	3/21/2020
3	ps	4/2/2020
;

proc sql;
 create table want as
 select *,date&amp;gt;=min(ifn(visit='pc',date,.)) as flag 
 from have
 group by id
 order by id,date;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 18:25:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696287#M212644</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-11-03T18:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations for an ID after specific date identified within the same ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696306#M212655</link>
      <description>Thank you! This was straightforward and easy to follow. I appreciate all the help. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 03 Nov 2020 19:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696306#M212655</guid>
      <dc:creator>ttbtink</dc:creator>
      <dc:date>2020-11-03T19:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying observations for an ID after specific date identified within the same ID.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696307#M212656</link>
      <description>&lt;P&gt;Thank you. I swear I am not a total noob to SAS in general, but I have my limits and do not know the more advanced coding techniques. I use this forum a lot of answer most my questions, and I always find an answer. I just couldn't find a solution for this specific problem. You were quick and helpful!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 19:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-observations-for-an-ID-after-specific-date/m-p/696307#M212656</guid>
      <dc:creator>ttbtink</dc:creator>
      <dc:date>2020-11-03T19:43:57Z</dc:date>
    </item>
  </channel>
</rss>

