<?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: Exclude records with perticular id based on condition in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Exclude-records-with-perticular-id-based-on-condition/m-p/72645#M1666</link>
    <description>SASg,&lt;BR /&gt;
&lt;BR /&gt;
First, a note of forum etiquette:  just post a question to one forum.&lt;BR /&gt;
&lt;BR /&gt;
Here is a solution.  It uses the RETAIN statement to create a variable that can be used as a flag to determine if the first record is a "Refferal".&lt;BR /&gt;
&lt;BR /&gt;
This could also be done with PROC SQL if one assumed the first date in an ID group is also the earliest and is unique within the group.  Both of those conditions exist in your example, but may not be there in a larger data set.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke&lt;BR /&gt;
&lt;BR /&gt;
DATA first;&lt;BR /&gt;
FORMAT DATE MMDDYY8.;&lt;BR /&gt;
INFORMAT date mmddyy8.;&lt;BR /&gt;
LENGTH status $8.;&lt;BR /&gt;
input id date status  days;&lt;BR /&gt;
cards;&lt;BR /&gt;
112 03/02/09 Approved 4&lt;BR /&gt;
112 03/03/09 Refferal 3&lt;BR /&gt;
112 03/04/09 shipped 2&lt;BR /&gt;
112 03/06/09 shipped 3&lt;BR /&gt;
113 04/01/08 Refferal 2&lt;BR /&gt;
113 04/02/09 Approved 1&lt;BR /&gt;
113 04/03/09 Ahipped 1&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
DATA results;&lt;BR /&gt;
SET first;&lt;BR /&gt;
BY id;&lt;BR /&gt;
RETAIN flag;&lt;BR /&gt;
IF first.id THEN&lt;BR /&gt;
  IF status='Refferal' THEN flag=1;&lt;BR /&gt;
                       ELSE flag=0;&lt;BR /&gt;
IF flag=0 THEN DELETE;&lt;BR /&gt;
DROP flag;&lt;BR /&gt;
RUN;</description>
    <pubDate>Mon, 06 Jun 2011 12:47:54 GMT</pubDate>
    <dc:creator>Doc_Duke</dc:creator>
    <dc:date>2011-06-06T12:47:54Z</dc:date>
    <item>
      <title>Exclude records with perticular id based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Exclude-records-with-perticular-id-based-on-condition/m-p/72644#M1665</link>
      <description>I'm learning sas......Trying to do below example....Please suggest me how to do it.&lt;BR /&gt;
Pls post the code.&lt;BR /&gt;
&lt;BR /&gt;
Below is the sample data.&lt;BR /&gt;
&lt;BR /&gt;
input:&lt;BR /&gt;
&lt;BR /&gt;
id date status days&lt;BR /&gt;
112 03/02/09 Approved 4&lt;BR /&gt;
112 03/03/09 Refferal 3&lt;BR /&gt;
112 03/04/09 shipped 2&lt;BR /&gt;
112 03/06/09 shipped 3&lt;BR /&gt;
113 04/01/08 Refferal 2&lt;BR /&gt;
113 04/02/09 Approved 1&lt;BR /&gt;
113 04/03/09 Ahipped 1&lt;BR /&gt;
&lt;BR /&gt;
I want to exclude the recordswith perticular id in output,if first date status is not equal to refferal.&lt;BR /&gt;
&lt;BR /&gt;
Output:&lt;BR /&gt;
&lt;BR /&gt;
id date status days&lt;BR /&gt;
113 04/01/08 Refferal 2&lt;BR /&gt;
113 04/02/09 Approved 1&lt;BR /&gt;
113 04/03/09 Ahipped 1&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
sasg</description>
      <pubDate>Fri, 03 Jun 2011 21:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Exclude-records-with-perticular-id-based-on-condition/m-p/72644#M1665</guid>
      <dc:creator>sasg</dc:creator>
      <dc:date>2011-06-03T21:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude records with perticular id based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Exclude-records-with-perticular-id-based-on-condition/m-p/72645#M1666</link>
      <description>SASg,&lt;BR /&gt;
&lt;BR /&gt;
First, a note of forum etiquette:  just post a question to one forum.&lt;BR /&gt;
&lt;BR /&gt;
Here is a solution.  It uses the RETAIN statement to create a variable that can be used as a flag to determine if the first record is a "Refferal".&lt;BR /&gt;
&lt;BR /&gt;
This could also be done with PROC SQL if one assumed the first date in an ID group is also the earliest and is unique within the group.  Both of those conditions exist in your example, but may not be there in a larger data set.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke&lt;BR /&gt;
&lt;BR /&gt;
DATA first;&lt;BR /&gt;
FORMAT DATE MMDDYY8.;&lt;BR /&gt;
INFORMAT date mmddyy8.;&lt;BR /&gt;
LENGTH status $8.;&lt;BR /&gt;
input id date status  days;&lt;BR /&gt;
cards;&lt;BR /&gt;
112 03/02/09 Approved 4&lt;BR /&gt;
112 03/03/09 Refferal 3&lt;BR /&gt;
112 03/04/09 shipped 2&lt;BR /&gt;
112 03/06/09 shipped 3&lt;BR /&gt;
113 04/01/08 Refferal 2&lt;BR /&gt;
113 04/02/09 Approved 1&lt;BR /&gt;
113 04/03/09 Ahipped 1&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
DATA results;&lt;BR /&gt;
SET first;&lt;BR /&gt;
BY id;&lt;BR /&gt;
RETAIN flag;&lt;BR /&gt;
IF first.id THEN&lt;BR /&gt;
  IF status='Refferal' THEN flag=1;&lt;BR /&gt;
                       ELSE flag=0;&lt;BR /&gt;
IF flag=0 THEN DELETE;&lt;BR /&gt;
DROP flag;&lt;BR /&gt;
RUN;</description>
      <pubDate>Mon, 06 Jun 2011 12:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Exclude-records-with-perticular-id-based-on-condition/m-p/72645#M1666</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-06-06T12:47:54Z</dc:date>
    </item>
  </channel>
</rss>

