<?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 How to sort by the most common combinations in proc tabulate. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-sort-by-the-most-common-combinations-in-proc-tabulate/m-p/540254#M7200</link>
    <description>&lt;P&gt;Hi, I have a 6700 person sample size with 9 binary (0 or 1) variables, I want to see the most common (maybe top 20) combinations of these 2^9 possible combinations since most combinations will have 0 or 1 observation. In&amp;nbsp;other words, I want to sort the proc tabulate output by "sum" or "n". I also create a variable called x, which equal 1 for every observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are my code and SAS output&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=paper order=freq;
class structural_flag social_support_flag behaviors_flag bills_flag housing_flag mental_health_flag resources_flag jail_flag food_cat;
var x;
table structural_flag*social_support_flag*behaviors_flag*bills_flag*housing_flag*mental_health_flag*resources_flag*jail_flag*food_cat,
	(x)*(Sum colpctn);run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WeChat Image_20190304162915.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27661iD7C7182504976C7B/image-size/large?v=v2&amp;amp;px=999" role="button" title="WeChat Image_20190304162915.png" alt="WeChat Image_20190304162915.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2019 21:49:29 GMT</pubDate>
    <dc:creator>ZZ_Zheng</dc:creator>
    <dc:date>2019-03-04T21:49:29Z</dc:date>
    <item>
      <title>How to sort by the most common combinations in proc tabulate.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sort-by-the-most-common-combinations-in-proc-tabulate/m-p/540254#M7200</link>
      <description>&lt;P&gt;Hi, I have a 6700 person sample size with 9 binary (0 or 1) variables, I want to see the most common (maybe top 20) combinations of these 2^9 possible combinations since most combinations will have 0 or 1 observation. In&amp;nbsp;other words, I want to sort the proc tabulate output by "sum" or "n". I also create a variable called x, which equal 1 for every observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are my code and SAS output&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=paper order=freq;
class structural_flag social_support_flag behaviors_flag bills_flag housing_flag mental_health_flag resources_flag jail_flag food_cat;
var x;
table structural_flag*social_support_flag*behaviors_flag*bills_flag*housing_flag*mental_health_flag*resources_flag*jail_flag*food_cat,
	(x)*(Sum colpctn);run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WeChat Image_20190304162915.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27661iD7C7182504976C7B/image-size/large?v=v2&amp;amp;px=999" role="button" title="WeChat Image_20190304162915.png" alt="WeChat Image_20190304162915.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 21:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sort-by-the-most-common-combinations-in-proc-tabulate/m-p/540254#M7200</guid>
      <dc:creator>ZZ_Zheng</dc:creator>
      <dc:date>2019-03-04T21:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort by the most common combinations in proc tabulate.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sort-by-the-most-common-combinations-in-proc-tabulate/m-p/540268#M7201</link>
      <description>&lt;P&gt;How about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql outobs=20;
create table paperTable from
select structural_flag, social_support_flag, behaviors_flag, bills_flag, housing_flag, 
    mental_health_flag, resources_flag, jail_flag, food_cat, count(*) as nn 
from paper
group by structural_flag, social_support_flag, behaviors_flag, bills_flag, housing_flag, 
    mental_health_flag, resources_flag, jail_flag, food_cat
order by nn desc;
quit;

proc tabulate data=paperTable order=data;
class structural_flag social_support_flag behaviors_flag bills_flag housing_flag mental_health_flag 
    resources_flag jail_flag food_cat;
var nn;
table structural_flag*social_support_flag*behaviors_flag*bills_flag*housing_flag*mental_health_flag*
    resources_flag*jail_flag*food_cat,
	nn*(Min colpctsum);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 22:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sort-by-the-most-common-combinations-in-proc-tabulate/m-p/540268#M7201</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-04T22:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort by the most common combinations in proc tabulate.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sort-by-the-most-common-combinations-in-proc-tabulate/m-p/540270#M7202</link>
      <description>&lt;P&gt;Thanks! PG Stats. It works well!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 22:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sort-by-the-most-common-combinations-in-proc-tabulate/m-p/540270#M7202</guid>
      <dc:creator>ZZ_Zheng</dc:creator>
      <dc:date>2019-03-04T22:32:23Z</dc:date>
    </item>
  </channel>
</rss>

