<?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: Selecting rows with only one unique value per subject in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321666#M71074</link>
    <description>&lt;P&gt;proc sort data=have dupout=want nodup;&lt;/P&gt;
&lt;P&gt;by venue sport;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want dataset will have your expected output.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Dec 2016 23:15:08 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2016-12-29T23:15:08Z</dc:date>
    <item>
      <title>Selecting rows with only one unique value per subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321665#M71073</link>
      <description>&lt;P&gt;The dataset looks something like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VENUE &amp;nbsp;SPORT&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Hockey&lt;/P&gt;&lt;P&gt;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Basketball&lt;/P&gt;&lt;P&gt;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Softball&amp;nbsp;&lt;/P&gt;&lt;P&gt;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Hockey&amp;nbsp;&lt;/P&gt;&lt;P&gt;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Softball&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Football&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to select only venues with one unique sport played there, so in this case Venue C would get selected because only one sport (softball) is played there. Any help would be greatly appreciated. Thanks. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 22:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321665#M71073</guid>
      <dc:creator>katsas1</dc:creator>
      <dc:date>2016-12-29T22:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows with only one unique value per subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321666#M71074</link>
      <description>&lt;P&gt;proc sort data=have dupout=want nodup;&lt;/P&gt;
&lt;P&gt;by venue sport;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;want dataset will have your expected output.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 23:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321666#M71074</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-12-29T23:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows with only one unique value per subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321667#M71075</link>
      <description>&lt;P&gt;Nodup deletes duplicated observations. I'm after retaining records with a single unique sport per venue and removing those with more than than one unique observation. Nodup retains venues with multiple unique observations.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 23:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321667#M71075</guid>
      <dc:creator>katsas1</dc:creator>
      <dc:date>2016-12-29T23:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows with only one unique value per subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321668#M71076</link>
      <description>&lt;P&gt;Another approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;tables venue * sport / noprint out=combinations;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=combinations;&lt;/P&gt;
&lt;P&gt;tables venue / noprint out=want (where=(count=1));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=want;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 23:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321668#M71076</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-29T23:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows with only one unique value per subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321679#M71083</link>
      <description>&lt;P&gt;SQL again offers a one step solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as&lt;/P&gt;
&lt;P&gt;select venue, &amp;nbsp;count(distinct sport) as num_sports&lt;/P&gt;
&lt;P&gt;from have&lt;/P&gt;
&lt;P&gt;group by venue&lt;/P&gt;
&lt;P&gt;where calculated num_sports=1;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2016 02:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321679#M71083</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-30T02:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows with only one unique value per subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321683#M71085</link>
      <description>&lt;PRE&gt;

data have;
input VENUE $ SPORT : $20.;
cards;
A           Hockey
B           Basketball
C           Softball 
B           Hockey 
C           Softball
A           Football 
;
run;
proc sql;
create table want as
 select *
  from have
   group by venue
    having count(distinct sport)=1;
quit;

&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Dec 2016 03:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321683#M71085</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-30T03:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows with only one unique value per subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321689#M71089</link>
      <description>&lt;P&gt;by data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have nodupkey;
by venue sport;
run;

data want;
set have;
by venue sport;
retain cnt;
if first.venue then cnt=1;
else cnt=cnt+1;
if last.venue and cnt&amp;lt;=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Dec 2016 04:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/321689#M71089</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-12-30T04:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows with only one unique value per subject</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/322200#M71270</link>
      <description>&lt;P&gt;This solution worked great. It's particularly useful if duplicate records need to be retain (like dollar amounts for each row). Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2017 16:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-with-only-one-unique-value-per-subject/m-p/322200#M71270</guid>
      <dc:creator>katsas1</dc:creator>
      <dc:date>2017-01-03T16:57:33Z</dc:date>
    </item>
  </channel>
</rss>

