<?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: Produce and count modes of combinations of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479100#M123612</link>
    <description>&lt;P&gt;To get counts (before limiting results to modes):&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 occupation * employer * qualification / out=want (drop=percent);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jul 2018 15:00:30 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-07-18T15:00:30Z</dc:date>
    <item>
      <title>Produce and count modes of combinations of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479087#M123604</link>
      <description>&lt;P&gt;Hello everyone !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data looks like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;occupation&lt;/TD&gt;&lt;TD&gt;employer&lt;/TD&gt;&lt;TD&gt;qualification&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dentist&lt;/TD&gt;&lt;TD&gt;Private&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;construction worker&lt;/TD&gt;&lt;TD&gt;Private&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;construction worker&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dentist&lt;/TD&gt;&lt;TD&gt;Private&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dentist&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;zoologist&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dentist&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dentist&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;police officer&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;police officer&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;police officer&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;police officer&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have the modes of the qualification variable for each occupation/employer couple. I'd also like to have counts for the modes. If there is an equality, the lowest qualification would be selected (lowest is 1 and highest is 9).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Result would be something like this :&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;occupation&lt;/TD&gt;&lt;TD&gt;employer&lt;/TD&gt;&lt;TD&gt;qualification&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dentist&lt;/TD&gt;&lt;TD&gt;Private&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dentist&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dentist&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;construction worker&lt;/TD&gt;&lt;TD&gt;Private&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;construction worker&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;zoologist&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;police officer&lt;/TD&gt;&lt;TD&gt;Public&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data has 1 million observations, so an sql approach is probably best.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 14:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479087#M123604</guid>
      <dc:creator>alex_philby</dc:creator>
      <dc:date>2018-07-18T14:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Produce and count modes of combinations of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479095#M123610</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input occupation &amp;amp; $25.	employer :$20.	qualification ;	
cards;
dentist		Private	9
construction worker		Private	2
construction worker		Public	2
dentist		Private	9
dentist		Public	8
zoologist	Public	8
dentist		Public	6
dentist		Public	6
police officer		Public	4
police officer		Public	4
police officer		Public	4
police officer		Public	4
;
proc sql;
create table want as
select   occupation,employer,qualification,count( qualification ) as count
from have
group by occupation,employer,qualification;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jul 2018 14:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479095#M123610</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-18T14:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Produce and count modes of combinations of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479100#M123612</link>
      <description>&lt;P&gt;To get counts (before limiting results to modes):&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 occupation * employer * qualification / out=want (drop=percent);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 15:00:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479100#M123612</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-18T15:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Produce and count modes of combinations of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479420#M123750</link>
      <description>&lt;P&gt;I already tried this but it takes hours before SAS finally crash down.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 08:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479420#M123750</guid>
      <dc:creator>alex_philby</dc:creator>
      <dc:date>2018-07-19T08:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Produce and count modes of combinations of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479426#M123756</link>
      <description>&lt;P&gt;It's difficult to believe that would happen with only 1M observations, but there is a workaround:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by occupation;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;by occupation;&lt;/P&gt;
&lt;P&gt;tables employer * qualification / out=want (drop=percent);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 09:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479426#M123756</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-19T09:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Produce and count modes of combinations of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479474#M123781</link>
      <description>&lt;P&gt;I think it's because at work we have to run SAS on some crappy virtual machine. I always have this problem when I run proc freq on 1M+ tables.&lt;/P&gt;&lt;P&gt;Ok so now I've got the counts but no way to find how to get the modes on SAS. Proc univariate only allows you to have the mode of one variable, not the modes of occupation*employer*qualification.&lt;/P&gt;&lt;P&gt;Any idea ?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 13:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479474#M123781</guid>
      <dc:creator>alex_philby</dc:creator>
      <dc:date>2018-07-19T13:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Produce and count modes of combinations of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479496#M123798</link>
      <description>&lt;P&gt;If your data set holding the counts is named COUNTS, you would just need to sort and subset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=counts;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by occupation employer descending count qualification;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set counts;&lt;/P&gt;
&lt;P&gt;by occupation employer descending count qualification;&lt;/P&gt;
&lt;P&gt;if first.count;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 13:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Produce-and-count-modes-of-combinations-of-variables/m-p/479496#M123798</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-19T13:48:25Z</dc:date>
    </item>
  </channel>
</rss>

