<?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 remove a group of observations based on conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210701#M39041</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;

data test;
input id gestage;
datalines;
1 36
1 38
2 .
2 41
3 30
3 .
3 32
4 19
4 41
5 35
5 36
5 36
;
run;
proc sql;
 create table want as
&amp;nbsp; select *
&amp;nbsp;&amp;nbsp; from test
&amp;nbsp;&amp;nbsp;&amp;nbsp; group by id
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; having nmiss(gestage)=0 and min(gestage) ge 20 and max(gestage) le 43;
quit;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 May 2015 12:31:37 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-05-07T12:31:37Z</dc:date>
    <item>
      <title>How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210694#M39034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to only keep the group of observations (by 'id') if the value of 'gestage' is not missing &lt;SPAN style="text-decoration: underline;"&gt;or&lt;/SPAN&gt; &amp;lt;/= 20 &lt;SPAN style="text-decoration: underline;"&gt;or&lt;/SPAN&gt; &amp;gt;/=43. Delete any group as long as one observation has a missing value in 'gestage' or an implausible value in 'gestage'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for helping!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt; input id gestage;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 36&lt;/P&gt;&lt;P&gt;1 38&lt;/P&gt;&lt;P&gt;2 .&lt;/P&gt;&lt;P&gt;2 41&lt;/P&gt;&lt;P&gt;3 30&lt;/P&gt;&lt;P&gt;3 .&lt;/P&gt;&lt;P&gt;3 32&lt;/P&gt;&lt;P&gt;4 19&lt;/P&gt;&lt;P&gt;4 41&lt;/P&gt;&lt;P&gt;5 35&lt;/P&gt;&lt;P&gt;5 36&lt;/P&gt;&lt;P&gt;5 36&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 00:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210694#M39034</guid>
      <dc:creator>burtsm</dc:creator>
      <dc:date>2015-05-07T00:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210695#M39035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the desired output.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 00:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210695#M39035</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-05-07T00:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210696#M39036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The desired output is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want&lt;/P&gt;&lt;P&gt; input id gestage;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 36&lt;/P&gt;&lt;P&gt;1 38&lt;/P&gt;&lt;P&gt;5 35&lt;/P&gt;&lt;P&gt;5 36&lt;/P&gt;&lt;P&gt;5 36&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 00:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210696#M39036</guid>
      <dc:creator>burtsm</dc:creator>
      <dc:date>2015-05-07T00:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210697#M39037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;This &amp;lt;/= 20 &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-decoration: underline; background-color: #ffffff;"&gt;or&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt; &amp;gt;/=43 does not cover the above output. Are you looking for &amp;gt;=20 or &amp;lt;=43?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 00:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210697#M39037</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-05-07T00:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210698#M39038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If any 'gestage' is less than 20 or greater than 43 (or missing), I want to delete the entire group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't have the 'greater than 43' in my example, but 'id'=4 has 'gestage'=19, so I want to delete all observations where 'id'=4. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 00:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210698#M39038</guid>
      <dc:creator>burtsm</dc:creator>
      <dc:date>2015-05-07T00:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210699#M39039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from test where id not in (select distinct id&amp;nbsp; from test&amp;nbsp; where gestage not between 20 and 43) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 01:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210699#M39039</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2015-05-07T01:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210700#M39040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test out=have;&lt;/P&gt;&lt;P&gt;by id gestage;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(drop=flag);&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;if first.id then flag=0;&lt;/P&gt;&lt;P&gt;if gestage=. or gestage&amp;lt;=20 or gestage&amp;gt;=43 then flag+1;&lt;/P&gt;&lt;P&gt;if flag=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 03:26:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210700#M39040</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-05-07T03:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210701#M39041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;

data test;
input id gestage;
datalines;
1 36
1 38
2 .
2 41
3 30
3 .
3 32
4 19
4 41
5 35
5 36
5 36
;
run;
proc sql;
 create table want as
&amp;nbsp; select *
&amp;nbsp;&amp;nbsp; from test
&amp;nbsp;&amp;nbsp;&amp;nbsp; group by id
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; having nmiss(gestage)=0 and min(gestage) ge 20 and max(gestage) le 43;
quit;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 12:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210701#M39041</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-07T12:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210702#M39042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id gestage;&lt;BR /&gt;datalines;&lt;BR /&gt;1 36&lt;BR /&gt;1 38&lt;BR /&gt;2 .&lt;BR /&gt;2 41&lt;BR /&gt;3 30&lt;BR /&gt;3 .&lt;BR /&gt;3 32&lt;BR /&gt;4 65&lt;BR /&gt;4 41&lt;BR /&gt;5 35&lt;BR /&gt;5 36&lt;BR /&gt;5 36&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=have;&lt;BR /&gt;by id gestage;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;merge have (in=h1)&lt;BR /&gt;have(rename=(gestage=gestage_drop)&lt;BR /&gt;where=(missing(gestage_drop) or gestage_drop lt 20 or gestage_drop gt 43) in=h2);&lt;/P&gt;&lt;P&gt;by id;&lt;BR /&gt;if h1 and not h2;&lt;/P&gt;&lt;P&gt;drop gestage_drop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 13:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210702#M39042</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2015-05-07T13:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210703#M39043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the helpful replies. As a novice SAS user, I learn so much from these forums!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 23:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210703#M39043</guid>
      <dc:creator>burtsm</dc:creator>
      <dc:date>2015-05-07T23:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210704#M39044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm having trouble applying the suggested code to another variable in my data set. I want to delete any group (by ID) as long as one observation has an implausible value for FIRSTBIRTH. That is, delete any group where FIRSTBIRTH=1 and BIRTHNUM ne 1 for any observation. This represents inaccurately reported data: a birth is noted as being a woman's first birth, but it's not consistent with the actual order of her births.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt; input id firstbirth birthnum;&lt;/P&gt;&lt;P&gt;datalines&lt;/P&gt;&lt;P&gt;1 1 1&lt;/P&gt;&lt;P&gt;1 1 2&lt;/P&gt;&lt;P&gt;2 1 1&lt;/P&gt;&lt;P&gt;2 0 2&lt;/P&gt;&lt;P&gt;2 0 3&lt;/P&gt;&lt;P&gt;3 1 1&lt;/P&gt;&lt;P&gt;3 1 2&lt;/P&gt;&lt;P&gt;3 1 3&lt;/P&gt;&lt;P&gt;4 1 1&lt;/P&gt;&lt;P&gt;4 0 2&lt;/P&gt;&lt;P&gt;4 0 3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is what I want:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; input id firstbirth birthnum;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;2 1 1&lt;/P&gt;&lt;P&gt;2 0 2&lt;/P&gt;&lt;P&gt;2 0 3&lt;/P&gt;&lt;P&gt;4 1 1&lt;/P&gt;&lt;P&gt;4 0 2&lt;/P&gt;&lt;P&gt;4 0 3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I used the following code:&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;proc sort data=have; &lt;/P&gt;&lt;P&gt;by id birthnum;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=flag);&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;if first.id then flag=0;&lt;/P&gt;&lt;P&gt;if FIRSTBIR=1 and BIRTHNUM ne 1 then flag+1;&lt;/P&gt;&lt;P&gt;if flag=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I get as output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; input id firstbirth birthnum;&lt;/P&gt;&lt;P&gt;datalines&lt;/P&gt;&lt;P&gt;1 1 1&lt;/P&gt;&lt;P&gt;2 1 1&lt;/P&gt;&lt;P&gt;2 0 2&lt;/P&gt;&lt;P&gt;2 0 3&lt;/P&gt;&lt;P&gt;3 1 1&lt;/P&gt;&lt;P&gt;4 1 1&lt;/P&gt;&lt;P&gt;4 0 2&lt;/P&gt;&lt;P&gt;4 0 3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run the code, only observations where FIRSTBIR=1 and BIRTHNUM ne 1 are deleted; not the entire group by ID where this occurs. Can someone please help me? Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jun 2015 23:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210704#M39044</guid>
      <dc:creator>burtsm</dc:creator>
      <dc:date>2015-06-08T23:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210705#M39045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have;&lt;/P&gt;&lt;P&gt;by id descending birthnum firstbirth;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by&amp;nbsp; id descending birthnum firstbirth ;&lt;/P&gt;&lt;P&gt;retain firstbirth2;&lt;/P&gt;&lt;P&gt;if first.id then firstbirth2=firstbirth;&lt;/P&gt;&lt;P&gt;if firstbirth2=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=want;&lt;/P&gt;&lt;P&gt;by&amp;nbsp; id&amp;nbsp; birthnum firstbirth;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 01:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210705#M39045</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-06-09T01:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210706#M39046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The SQL solutions might be the easiest way.&amp;nbsp; This would be the right approach for a DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; wanted='Y';&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if firstbirth=1 and birthnum ne 1 then wanted='N';&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if wanted='Y' then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop wanted;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 02:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210706#M39046</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-06-09T02:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210707#M39047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the replies! @Astounding the approach you posted worked great. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 23:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/210707#M39047</guid>
      <dc:creator>burtsm</dc:creator>
      <dc:date>2015-06-09T23:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/584459#M166474</link>
      <description>&lt;P&gt;Alternatively&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as select id, gestage from test group by id having sum(gestage=. or gestage &amp;lt;=20 or gestage &amp;gt;=43)=0 ; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Aug 2019 08:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/584459#M166474</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-08-28T08:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a group of observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/584500#M166501</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45258"&gt;@burtsm&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An alternative approach is to use a hash table lookup.&lt;/P&gt;
&lt;P&gt;You first load the hash table with the id's matching the condition you don't want. You then delete all records who have a match with the hash table over id.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id firstbirth birthnum;
  datalines;
1 1 1
1 1 2
2 1 1
2 0 2
2 0 3
3 1 1
3 1 2
3 1 3
4 1 1
4 0 2
4 0 3
;

data want;
  if _n_=1 then
    do;
      dcl hash h1(dataset:'have(where=(FIRSTBIRTH=1 and BIRTHNUM ne 1))');
      h1.defineKey('id');
      h1.defineDone();
    end;
  set have;
  if h1.check()=0 then delete;
run;

proc print data=want;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using hash tables has the big advantage that your source data doesn't need to be sorted.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 11:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-a-group-of-observations-based-on-conditions/m-p/584500#M166501</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-08-28T11:13:51Z</dc:date>
    </item>
  </channel>
</rss>

