<?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: select most frequent character (i.e., country) in each group (i.e. company) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/select-most-frequent-character-i-e-country-in-each-group-i-e/m-p/517169#M139756</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards dsd truncover;
input (country company) (:$10.);
cards;
US, apple
US, apple
GB, apple
US, apple
CH, pear
CH, pear
US, pear
;

proc sql;
create table want(drop=c) as
select *
from (select company,country, count(company) as c from have group by company,country)
group by company
having c=max(c);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Nov 2018 18:11:02 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-11-29T18:11:02Z</dc:date>
    <item>
      <title>select most frequent character (i.e., country) in each group (i.e. company)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-most-frequent-character-i-e-country-in-each-group-i-e/m-p/517157#M139748</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to chose country character which record most frequently with the company.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;country, company
US, apple
US, apple
GB, apple
US, apple
CH, pear
CH, pear
US, pear&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like the result looks like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;country, company
US, apple
CH, pear&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please give me some suggestion about it?&lt;/P&gt;&lt;P&gt;thanks in adanvce&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 17:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-most-frequent-character-i-e-country-in-each-group-i-e/m-p/517157#M139748</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-11-29T17:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: select most frequent character (i.e., country) in each group (i.e. company)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-most-frequent-character-i-e-country-in-each-group-i-e/m-p/517159#M139750</link>
      <description>&lt;P&gt;If I understand then something like this perhaps:&lt;/P&gt;
&lt;PRE&gt;proc freq data=have noprint;
   table company*country/out=work.temp(drop=percent);
run;

proc sort data=work.temp;
  by company descending count;
run;

data want;
  set work.temp;
  by company;
  if first.company;
run;&lt;/PRE&gt;
&lt;P&gt;is just one way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 17:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-most-frequent-character-i-e-country-in-each-group-i-e/m-p/517159#M139750</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-29T17:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: select most frequent character (i.e., country) in each group (i.e. company)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-most-frequent-character-i-e-country-in-each-group-i-e/m-p/517169#M139756</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards dsd truncover;
input (country company) (:$10.);
cards;
US, apple
US, apple
GB, apple
US, apple
CH, pear
CH, pear
US, pear
;

proc sql;
create table want(drop=c) as
select *
from (select company,country, count(company) as c from have group by company,country)
group by company
having c=max(c);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2018 18:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-most-frequent-character-i-e-country-in-each-group-i-e/m-p/517169#M139756</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-29T18:11:02Z</dc:date>
    </item>
  </channel>
</rss>

