<?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 print data order by sum, not sort by variable? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-print-data-order-by-sum-not-sort-by-variable/m-p/814404#M40190</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Have a 4 column data as below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Michaelcwang2_0-1653035447278.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71658i9FD71613DFFF5297/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Michaelcwang2_0-1653035447278.png" alt="Michaelcwang2_0-1653035447278.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And code as below:&lt;/P&gt;&lt;PRE&gt;title1 'WORK.BINORI 的清單資料';

proc sort data=WORK.BINORI out=WORK.SORTTEMP;
	by IBVEND;
run;

proc print data=WORK.SORTTEMP label;
	by IBVEND;
	sum COUNT;
	id NORI;
	
run;&lt;/PRE&gt;&lt;P&gt;And result as below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Michaelcwang2_1-1653035628368.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71659i38EBF45751CCBA56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Michaelcwang2_1-1653035628368.png" alt="Michaelcwang2_1-1653035628368.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;NORI is binary as null or the 3 Chinese characters.&lt;/P&gt;&lt;P&gt;However try to print data in the order by sum of Count, not by sorted variable "IBVEND", appreciate any comment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 May 2022 08:42:14 GMT</pubDate>
    <dc:creator>Michaelcwang2</dc:creator>
    <dc:date>2022-05-20T08:42:14Z</dc:date>
    <item>
      <title>How to print data order by sum, not sort by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-print-data-order-by-sum-not-sort-by-variable/m-p/814404#M40190</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Have a 4 column data as below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Michaelcwang2_0-1653035447278.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71658i9FD71613DFFF5297/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Michaelcwang2_0-1653035447278.png" alt="Michaelcwang2_0-1653035447278.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And code as below:&lt;/P&gt;&lt;PRE&gt;title1 'WORK.BINORI 的清單資料';

proc sort data=WORK.BINORI out=WORK.SORTTEMP;
	by IBVEND;
run;

proc print data=WORK.SORTTEMP label;
	by IBVEND;
	sum COUNT;
	id NORI;
	
run;&lt;/PRE&gt;&lt;P&gt;And result as below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Michaelcwang2_1-1653035628368.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71659i38EBF45751CCBA56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Michaelcwang2_1-1653035628368.png" alt="Michaelcwang2_1-1653035628368.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;NORI is binary as null or the 3 Chinese characters.&lt;/P&gt;&lt;P&gt;However try to print data in the order by sum of Count, not by sorted variable "IBVEND", appreciate any comment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 08:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-print-data-order-by-sum-not-sort-by-variable/m-p/814404#M40190</guid>
      <dc:creator>Michaelcwang2</dc:creator>
      <dc:date>2022-05-20T08:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to print data order by sum, not sort by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-print-data-order-by-sum-not-sort-by-variable/m-p/814408#M40191</link>
      <description>&lt;P&gt;Using BY in proc sort will always result in output being sorted by the variable(s) listed in the the statement. Instead of using proc sort + proc print, you could use proc summary + sort + print to get what you want.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 09:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-print-data-order-by-sum-not-sort-by-variable/m-p/814408#M40191</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-05-20T09:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to print data order by sum, not sort by variable?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-print-data-order-by-sum-not-sort-by-variable/m-p/814457#M40194</link>
      <description>&lt;P&gt;Here is an example of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt; suggestion with a data set you should have available to test the code with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc summary data=sashelp.class nway;
   class age;
   var height;
   output out=agesummary (drop= _type_ _freq_) sum=;
run;

proc sort data=agesummary;
   by descending height;
run;

proc print data=agesummary noobs;
   var age height;
run;

&lt;/PRE&gt;
&lt;P&gt;You could have more variables on the CLASS statement if needed for the groups, more than one output variable created and multiple statistics from the Proc Summary output. Then sort that resulting data set as desired.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 14:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-print-data-order-by-sum-not-sort-by-variable/m-p/814457#M40194</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-05-20T14:57:08Z</dc:date>
    </item>
  </channel>
</rss>

