<?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: MULTIPLE Qs- Top5/Bottom5 &amp;amp; Comparison of Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798883#M314062</link>
    <description>&lt;P&gt;It sounds like you want the Top and Bottom 5 categories by percentage. See that article, &lt;A href="https://blogs.sas.com/content/iml/2018/06/04/top-10-table-bar-chart.html" target="_self"&gt;"An easy way to make a "Top 10" table and bar chart in SAS."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here is an example of how to use the technique to get the Top and Bottom 5:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* write the sorted frequencies to a data set */
proc freq data=sashelp.cars ORDER=FREQ noprint;
  table make / out=FreqOut;
run;

/* print the top 5 */
%let MaxN = 5;
title "Top &amp;amp;MaxN Categories";
proc print data=FreqOut(obs=&amp;amp;MaxN);
run;

/* print the bottom 5 */
proc sort data=FreqOut; by percent; run;
title "Bottom &amp;amp;MaxN Categories";
proc print data=FreqOut(obs=&amp;amp;MaxN);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 26 Feb 2022 19:21:43 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-02-26T19:21:43Z</dc:date>
    <item>
      <title>MULTIPLE Qs- Top5/Bottom5 &amp; Comparison of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798845#M314049</link>
      <description>&lt;P&gt;I have a couple of questions and let me know if I need to elaborate more!&lt;/P&gt;&lt;P&gt;1.) How can I get the top 5 and the bottom 5 observations of a (categorical) value while also showing the percentages ?&lt;/P&gt;&lt;P&gt;2.) How do I make it so a large piece of data where it's trying to find a relationship, download to excel? So far I've used:&lt;/P&gt;&lt;P&gt;proc compare base=work.details;&lt;BR /&gt;var income;&lt;BR /&gt;with ed;&lt;BR /&gt;title 'Comparison of Variables in the Same Data Set';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;However, it doesn't translate to Excel so there's not a way for me to make a graph.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 14:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798845#M314049</guid>
      <dc:creator>ccherrub</dc:creator>
      <dc:date>2022-02-26T14:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: MULTIPLE Qs- Top5/Bottom5 &amp; Comparison of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798846#M314050</link>
      <description>&lt;P&gt;1) Do you mean categories with the top 5 frequencies, or top 5 percents?&lt;/P&gt;
&lt;P&gt;2) "How do I make it so a large piece of data where it's trying to find a relationship, download to excel?" Explain further, I don't understand.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 14:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798846#M314050</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-26T14:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: MULTIPLE Qs- Top5/Bottom5 &amp; Comparison of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798847#M314051</link>
      <description>1.) So I'm trying to get the top/bottom 5 states in regards to how many observations are in each state and the percentage out of the whole in regards to observations as well. I.e.&lt;BR /&gt;STATES OBSVERATIONS PERCENTAGES&lt;BR /&gt;NY 2378 2%&lt;BR /&gt;TX 45678 3.8%&lt;BR /&gt;CA 100 .0008%&lt;BR /&gt;&lt;BR /&gt;Or something like that. (These aren't my actual numbers, I tried to make them as proportional as possible if that matters)&lt;BR /&gt;&lt;BR /&gt;2.) When I used the code in the initial post, it gave me relationship data but it was in a way that didn't make it possible for me to download it to excel or use excel to find a relationship chart. I'm pretty certain it's the code I used. I'll attach the question I'm studying for:&lt;BR /&gt;&lt;BR /&gt;Use a graph of your choice (i.e., not a table) to display (and compare) the average income of individuals with different level of education. You may use Excel to create your graph once you extracted the necessary information from SAS. Include this graph in your write-up and discuss it.</description>
      <pubDate>Sat, 26 Feb 2022 15:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798847#M314051</guid>
      <dc:creator>ccherrub</dc:creator>
      <dc:date>2022-02-26T15:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: MULTIPLE Qs- Top5/Bottom5 &amp; Comparison of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798855#M314052</link>
      <description>&lt;P&gt;1) You want to use &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/procstat/procstat_freq_syntax01.htm" target="_self"&gt;PROC FREQ&lt;/A&gt; on your data, with the option ORDER=FREQ&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) You want to produce a scatter plot, you can use PROC SGPLOT with the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/grstatproc/p1lcbd3lhs3t3bn1jk6d8sjt2yqx.htm" target="_self"&gt;SCATTER statement&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 15:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798855#M314052</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-26T15:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: MULTIPLE Qs- Top5/Bottom5 &amp; Comparison of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798874#M314057</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For 1.) , see these two blogs :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Selecting the top n% and bottom n% of observations from a data set&lt;BR /&gt;By Kathryn McLawhorn on SAS Users July 21, 2017&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/sgf/2017/07/21/selecting-the-top-n-and-bottom-n-of-observations-from-a-data-set/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2017/07/21/selecting-the-top-n-and-bottom-n-of-observations-from-a-data-set/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4 ways to find the k smallest and largest data values in SAS&lt;BR /&gt;By Rick Wicklin on The DO Loop January 26, 2022&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2022/01/26/k-smallest-largest-data.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2022/01/26/k-smallest-largest-data.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 17:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798874#M314057</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-02-26T17:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: MULTIPLE Qs- Top5/Bottom5 &amp; Comparison of Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798883#M314062</link>
      <description>&lt;P&gt;It sounds like you want the Top and Bottom 5 categories by percentage. See that article, &lt;A href="https://blogs.sas.com/content/iml/2018/06/04/top-10-table-bar-chart.html" target="_self"&gt;"An easy way to make a "Top 10" table and bar chart in SAS."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here is an example of how to use the technique to get the Top and Bottom 5:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* write the sorted frequencies to a data set */
proc freq data=sashelp.cars ORDER=FREQ noprint;
  table make / out=FreqOut;
run;

/* print the top 5 */
%let MaxN = 5;
title "Top &amp;amp;MaxN Categories";
proc print data=FreqOut(obs=&amp;amp;MaxN);
run;

/* print the bottom 5 */
proc sort data=FreqOut; by percent; run;
title "Bottom &amp;amp;MaxN Categories";
proc print data=FreqOut(obs=&amp;amp;MaxN);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 19:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MULTIPLE-Qs-Top5-Bottom5-amp-Comparison-of-Variables/m-p/798883#M314062</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-02-26T19:21:43Z</dc:date>
    </item>
  </channel>
</rss>

