<?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 can I find out values which are unique to a group? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619116#M19339</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input pname $ part $;
datalines;
program1 001
program2 002
program3 001
program3 004
program4 005
program4 005
program5 005
;
run;



data want;
 if _n_=1 then do;
  if 0 then set have;
  declare hash h1();
  h1.definekey('part');
  h1.definedone();
  declare hash h2();
  h2.definekey('part','pname');
  h2.definedone();
 end;
set have;
if h1.check() ne 0 then do;h1.add();h2.ref();output;end;
 else if h2.check()=0 then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Jan 2020 12:05:32 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2020-01-22T12:05:32Z</dc:date>
    <item>
      <title>How can I find out values which are unique to a group?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619030#M19316</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two columns in a table, Program name and Part numbers. I need to find out the part numbers which are unique to a program Name. The output can contain the same part number within a program but not in any other program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input pname $ part $;
datalines;
program1 001
program2 002
program3 001
program3 004&lt;BR /&gt;program4 005
program4 005
program5 005
;
run;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="have.png" style="width: 141px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35544i3CFCC090EF770EBB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="have.png" alt="have.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="want.png" style="width: 188px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35545i26C7BD793C77E156/image-dimensions/188x139?v=v2" width="188" height="139" role="button" title="want.png" alt="want.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 03:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619030#M19316</guid>
      <dc:creator>subhroster</dc:creator>
      <dc:date>2020-01-22T03:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I find out values which are unique to a group?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619034#M19318</link>
      <description>&lt;P&gt;Essentially this means you want the parts that have a single program name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or at least that's what it seems but your output doesn't match your description. Part 1 is in Program 1 and Program 3? I thought you may want the opposite but the P005 is in Program 4/5 and you have it included for Program4.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The output can contain the same part number within a program but not in any other program.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In general, this is how you do&amp;nbsp;something like this though:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select * from have where part in (
select part
from have
group by part
having count(distinct pname)=1);


quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212184"&gt;@subhroster&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two columns in a table, Program name and Part numbers. I need to find out the part numbers which are unique to a program Name. The output can contain the same part number within a program but not in any other program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input pname $ part $;
datalines;
program1 001
program2 002
program3 001
program3 004&lt;BR /&gt;program4 005
program4 005
program5 005
;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="have.png" style="width: 141px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35544i3CFCC090EF770EBB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="have.png" alt="have.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="want.png" style="width: 188px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35545i26C7BD793C77E156/image-dimensions/188x139?v=v2" width="188" height="139" role="button" title="want.png" alt="want.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 04:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619034#M19318</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-22T04:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I find out values which are unique to a group?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619058#M19324</link>
      <description>&lt;P&gt;Hi Reeza&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thanks. This is valid.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 07:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619058#M19324</guid>
      <dc:creator>subhroster</dc:creator>
      <dc:date>2020-01-22T07:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I find out values which are unique to a group?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619116#M19339</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input pname $ part $;
datalines;
program1 001
program2 002
program3 001
program3 004
program4 005
program4 005
program5 005
;
run;



data want;
 if _n_=1 then do;
  if 0 then set have;
  declare hash h1();
  h1.definekey('part');
  h1.definedone();
  declare hash h2();
  h2.definekey('part','pname');
  h2.definedone();
 end;
set have;
if h1.check() ne 0 then do;h1.add();h2.ref();output;end;
 else if h2.check()=0 then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jan 2020 12:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-can-I-find-out-values-which-are-unique-to-a-group/m-p/619116#M19339</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-01-22T12:05:32Z</dc:date>
    </item>
  </channel>
</rss>

