<?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 Proc Summary-Order of raws in output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/655794#M196741</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to ask what is the default way that SAS sort the rows (of class variable) in proc summary.&lt;/P&gt;
&lt;P&gt;for example:&lt;/P&gt;
&lt;P&gt;in this example order of rows is:&lt;/P&gt;
&lt;P&gt;10-20K&lt;BR /&gt;100K+&lt;BR /&gt;20-50K&lt;BR /&gt;5-10K&lt;BR /&gt;50-100K&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May anyone explain why the order is like that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc format;
value FF2T
0 &amp;lt;- 1000='0-1K'
1000 &amp;lt;- 5000='1-5K'
5000 &amp;lt;- 10000='5-10K'
10000 &amp;lt;- 20000='10-20K'
20000 &amp;lt;- 50000='20-50K'
50000 &amp;lt;- 100000='50-100K'
100000 &amp;lt;- high='100K+';
;
run;
Data Sedan_cars;
set sashelp.cars(where=(Type='Sedan'));
Invoice_=put(Invoice,FF2T.);
run;

proc summary data=Sedan_cars  nway missing ;
class Type Invoice_ ;
var Invoice;
output out=summaryTbl(drop=_type_) sum= mean= /autoname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Jun 2020 03:53:01 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-06-10T03:53:01Z</dc:date>
    <item>
      <title>Proc Summary-Order of raws in output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/655794#M196741</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to ask what is the default way that SAS sort the rows (of class variable) in proc summary.&lt;/P&gt;
&lt;P&gt;for example:&lt;/P&gt;
&lt;P&gt;in this example order of rows is:&lt;/P&gt;
&lt;P&gt;10-20K&lt;BR /&gt;100K+&lt;BR /&gt;20-50K&lt;BR /&gt;5-10K&lt;BR /&gt;50-100K&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May anyone explain why the order is like that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc format;
value FF2T
0 &amp;lt;- 1000='0-1K'
1000 &amp;lt;- 5000='1-5K'
5000 &amp;lt;- 10000='5-10K'
10000 &amp;lt;- 20000='10-20K'
20000 &amp;lt;- 50000='20-50K'
50000 &amp;lt;- 100000='50-100K'
100000 &amp;lt;- high='100K+';
;
run;
Data Sedan_cars;
set sashelp.cars(where=(Type='Sedan'));
Invoice_=put(Invoice,FF2T.);
run;

proc summary data=Sedan_cars  nway missing ;
class Type Invoice_ ;
var Invoice;
output out=summaryTbl(drop=_type_) sum= mean= /autoname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jun 2020 03:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/655794#M196741</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-06-10T03:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Summary-Order of raws in output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/655797#M196744</link>
      <description>&lt;P&gt;your format is a character and imagine this is from a dictionary then the order will be as follows and hence the discrepancy&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;10&lt;/P&gt;
&lt;P&gt;100&lt;/P&gt;
&lt;P&gt;11&lt;/P&gt;
&lt;P&gt;110&lt;/P&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;P&gt;20&lt;/P&gt;
&lt;P&gt;21&lt;/P&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;P&gt;30&lt;/P&gt;
&lt;P&gt;300&lt;/P&gt;
&lt;P&gt;31&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;in order for things to be consistent make them all two or three positional digits by padding with leading zeros. Good luck&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 04:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/655797#M196744</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-10T04:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Summary-Order of raws in output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/655856#M196745</link>
      <description>&lt;P&gt;Follow Maxim 1 and Read the Documentation, in this case, of the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=p0gpxoqczfzcyln13ma53kpq38lo.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;CLASS Statement&lt;/A&gt;. Hint: look for "Order".&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 04:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/655856#M196745</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-10T04:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Summary-Order of raws in output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/656357#M196792</link>
      <description>&lt;P&gt;This was all explained in a thread you started two weeks ago&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/proc-summary-order-of-categories-is-not-as-I-want/m-p/651326#M195417" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/proc-summary-order-of-categories-is-not-as-I-want/m-p/651326#M195417&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you create INVOICE_ as a character variable, it will sort as character variable (which sorts alphabetically), where strings that begin with 1 come before strings that begin as 2.&amp;nbsp;You should not create INVOICE_ as a character variable and then try to jump through hoops to get it to sort as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you create INVOICE_ as a numeric variable, it will sort as numeric, and sort in the desired order. My reply in that thread shows you exactly how to do it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Summary: character variables sort alphabetically. Numeric variables will sort numerically. In this case, you want it to be a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 11:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/656357#M196792</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-10T11:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Summary-Order of raws in output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/656429#M196819</link>
      <description>&lt;P&gt;You might try&amp;nbsp; making a format that sorts in the order that you want things, such as:&lt;/P&gt;
&lt;PRE&gt;proc format;
value FF2T
0      &amp;lt;- 1000  ='  0-1K'
1000   &amp;lt;- 5000  ='  1-5K'
5000   &amp;lt;- 10000 ='  5-10K'
10000  &amp;lt;- 20000 =' 10-20K'
20000  &amp;lt;- 50000 =' 20-50K'
50000  &amp;lt;- 100000=' 50-100K'
100000 &amp;lt;- high  ='100K+';
;&lt;/PRE&gt;
&lt;P&gt;Especially if you are going to insist on making character variables. If you use the numeric value directly then you can usually use the internal value to control order. But that choice is taken away with character variables, or at least it will behave quite differently.&lt;/P&gt;
&lt;P&gt;Notice that nicely formatted code would show the "sort order" of the character values this way. The space will sort before 1, 2, 3 etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 14:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Summary-Order-of-raws-in-output/m-p/656429#M196819</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-10T14:18:55Z</dc:date>
    </item>
  </channel>
</rss>

