<?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 Determine maximum count of distinct values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Determine-maximum-count-of-distinct-values/m-p/747221#M234491</link>
    <description>&lt;P&gt;Is there was a combine the two sql steps below into one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Sample data*/&lt;BR /&gt;data one;&lt;BR /&gt;input x $1. y 1.;&lt;BR /&gt;datalines;&lt;BR /&gt;a1&lt;BR /&gt;a2&lt;BR /&gt;a1&lt;BR /&gt;b1&lt;BR /&gt;b1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;/*determine count of distinct values of y for each value of x*/&lt;BR /&gt;create table two as select x, count(distinct y) as cnt_y&lt;BR /&gt;from one&lt;BR /&gt;group by x;&lt;BR /&gt;/*determine maximum value of distinct value count*/&lt;BR /&gt;select max(cnt_y)&lt;BR /&gt;from two;&lt;BR /&gt;quit;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jun 2021 21:32:19 GMT</pubDate>
    <dc:creator>Batman</dc:creator>
    <dc:date>2021-06-10T21:32:19Z</dc:date>
    <item>
      <title>Determine maximum count of distinct values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determine-maximum-count-of-distinct-values/m-p/747221#M234491</link>
      <description>&lt;P&gt;Is there was a combine the two sql steps below into one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Sample data*/&lt;BR /&gt;data one;&lt;BR /&gt;input x $1. y 1.;&lt;BR /&gt;datalines;&lt;BR /&gt;a1&lt;BR /&gt;a2&lt;BR /&gt;a1&lt;BR /&gt;b1&lt;BR /&gt;b1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;/*determine count of distinct values of y for each value of x*/&lt;BR /&gt;create table two as select x, count(distinct y) as cnt_y&lt;BR /&gt;from one&lt;BR /&gt;group by x;&lt;BR /&gt;/*determine maximum value of distinct value count*/&lt;BR /&gt;select max(cnt_y)&lt;BR /&gt;from two;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 21:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determine-maximum-count-of-distinct-values/m-p/747221#M234491</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2021-06-10T21:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Determine maximum count of distinct values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determine-maximum-count-of-distinct-values/m-p/747223#M234492</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9248"&gt;@Batman&lt;/a&gt;&amp;nbsp; You could do in one step that still doesn't mean it's a one pass though. For brevity, you could modify the code to-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 select max(cnt_y) 
 from (select count(distinct y) as cnt_y from one group by x);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However the above is still 2 passes akin to your solution&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 21:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determine-maximum-count-of-distinct-values/m-p/747223#M234492</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-06-10T21:43:57Z</dc:date>
    </item>
  </channel>
</rss>

