<?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: Only keep matching values in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411916#M26467</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Key     Px_Type $  Match_ID $;
cards;
1115    L               0001a
1116    D              0001a
1117    D              0004b
1118    L               0003b
;
run;

proc sql;
select *
 from have
  group by  Match_ID
   having count(distinct  Px_Type) ne 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Nov 2017 13:26:06 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-11-09T13:26:06Z</dc:date>
    <item>
      <title>Only keep matching values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411590#M26444</link>
      <description>&lt;P&gt;I have a dataset with patient_type=living and patient_type=deceased, as well as a column for match_ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to keep only observations where&amp;nbsp;&lt;SPAN&gt;patient_type=living and&amp;nbsp;patient_type=deceased have the same&amp;nbsp;match_ID, and exclude everything else.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Key&amp;nbsp; &amp;nbsp; &amp;nbsp;Px_Type&amp;nbsp; &amp;nbsp;Match_ID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1115&amp;nbsp; &amp;nbsp; L&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0001a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1116&amp;nbsp; &amp;nbsp; D&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0001a&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1117&amp;nbsp; &amp;nbsp; D&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0004b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1118&amp;nbsp; &amp;nbsp; L&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0003b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to keep observations 1115 (L) and 1116 (D) since they have the same match_ID. Is there a way to approach this in SAS?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 17:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411590#M26444</guid>
      <dc:creator>jcapua2</dc:creator>
      <dc:date>2017-11-08T17:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Only keep matching values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411658#M26446</link>
      <description>&lt;P&gt;If your data is sorted then you could try a statement like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if compress(&lt;SPAN&gt;Match_ID&lt;/SPAN&gt;) eq lag(compress(&lt;SPAN&gt;Match_ID&lt;/SPAN&gt;)) and compress(&lt;SPAN&gt;Px_Type&lt;/SPAN&gt;) in ( "D","L") then output ;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 19:49:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411658#M26446</guid>
      <dc:creator>RW</dc:creator>
      <dc:date>2017-11-08T19:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Only keep matching values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411684#M26447</link>
      <description>&lt;P&gt;Is there other data that has to be preserved? If so, what exactly would the result look like?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 20:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411684#M26447</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-08T20:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Only keep matching values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411916#M26467</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Key     Px_Type $  Match_ID $;
cards;
1115    L               0001a
1116    D              0001a
1117    D              0004b
1118    L               0003b
;
run;

proc sql;
select *
 from have
  group by  Match_ID
   having count(distinct  Px_Type) ne 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 13:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Only-keep-matching-values/m-p/411916#M26467</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-09T13:26:06Z</dc:date>
    </item>
  </channel>
</rss>

