<?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 Delete rows with condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-with-condition/m-p/889914#M351605</link>
    <description>&lt;P&gt;I want to keep all rows of same id as long as this id has at least one record of type=2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dataset I have is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input id 	type	visit_date :yymmdd10.;
   format visit_date yymmdd10.;
datalines;
1 	1 	2000-01-01
1 	2 	2005-01-02
1 	2 	2006-01-03
1 	3 	2007-01-04
1 	5 	2010-01-05
2 	. 	2000-01-06
2 	. 	2000-01-07
2 	. 	2000-01-08
3 	2 	2001-01-09
3 	. 	2006-01-10
3 	2 	2007-01-11
3 	. 	2008-01-12
4 	. 	2006-01-10
4 	3 	2007-01-11
4 	1 	2008-01-12
5 	2 	2007-01-11
5 	2 	2008-01-12
5 	2 	2009-01-10
5 	2 	2010-01-11
6 	2 	2002-01-12
6 	1 	2003-01-10
6 	. 	2004-01-11
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input id 	type	visit_date :yymmdd10.;
   format visit_date yymmdd10.;
datalines;
1 	1 	2000-01-01
1 	2 	2005-01-02
1 	2 	2006-01-03
1 	3 	2007-01-04
1 	5 	2010-01-05
3 	2 	2001-01-09
3 	. 	2006-01-10
3 	2 	2007-01-11
3 	. 	2008-01-12
5 	2 	2007-01-11
5 	2 	2008-01-12
5 	2 	2009-01-10
5 	2 	2010-01-11
6 	2 	2002-01-12
6 	1 	2003-01-10
6 	. 	2004-01-11
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 Aug 2023 15:25:50 GMT</pubDate>
    <dc:creator>zihdonv19</dc:creator>
    <dc:date>2023-08-18T15:25:50Z</dc:date>
    <item>
      <title>Delete rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-with-condition/m-p/889914#M351605</link>
      <description>&lt;P&gt;I want to keep all rows of same id as long as this id has at least one record of type=2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dataset I have is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input id 	type	visit_date :yymmdd10.;
   format visit_date yymmdd10.;
datalines;
1 	1 	2000-01-01
1 	2 	2005-01-02
1 	2 	2006-01-03
1 	3 	2007-01-04
1 	5 	2010-01-05
2 	. 	2000-01-06
2 	. 	2000-01-07
2 	. 	2000-01-08
3 	2 	2001-01-09
3 	. 	2006-01-10
3 	2 	2007-01-11
3 	. 	2008-01-12
4 	. 	2006-01-10
4 	3 	2007-01-11
4 	1 	2008-01-12
5 	2 	2007-01-11
5 	2 	2008-01-12
5 	2 	2009-01-10
5 	2 	2010-01-11
6 	2 	2002-01-12
6 	1 	2003-01-10
6 	. 	2004-01-11
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input id 	type	visit_date :yymmdd10.;
   format visit_date yymmdd10.;
datalines;
1 	1 	2000-01-01
1 	2 	2005-01-02
1 	2 	2006-01-03
1 	3 	2007-01-04
1 	5 	2010-01-05
3 	2 	2001-01-09
3 	. 	2006-01-10
3 	2 	2007-01-11
3 	. 	2008-01-12
5 	2 	2007-01-11
5 	2 	2008-01-12
5 	2 	2009-01-10
5 	2 	2010-01-11
6 	2 	2002-01-12
6 	1 	2003-01-10
6 	. 	2004-01-11
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2023 15:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-with-condition/m-p/889914#M351605</guid>
      <dc:creator>zihdonv19</dc:creator>
      <dc:date>2023-08-18T15:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delete rows with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-rows-with-condition/m-p/889920#M351607</link>
      <description>&lt;P&gt;There are multiple ways to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select * 
	from have
	where id in 
		(select distinct id
		from have
		where type = 2);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2023 15:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-rows-with-condition/m-p/889920#M351607</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2023-08-18T15:38:33Z</dc:date>
    </item>
  </channel>
</rss>

