<?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 order of categories in summary table produced by proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582679#M165784</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a problem.&lt;/P&gt;
&lt;P&gt;I use CASE when statement to create a new variable called "IND".&lt;/P&gt;
&lt;P&gt;As you can see I create different groups .&lt;/P&gt;
&lt;P&gt;Later I will calculate summary statistics for each group.&lt;/P&gt;
&lt;P&gt;I want that the order of the groups will be as it appear here:&lt;/P&gt;
&lt;P&gt;'a1.Case1'&lt;/P&gt;
&lt;P&gt;'a2.Case2'&lt;/P&gt;
&lt;P&gt;'a3.Case3'&lt;/P&gt;
&lt;P&gt;'a4.&amp;lt;Lower than -100K'&lt;/P&gt;
&lt;P&gt;'a5.[-100,-50)'&lt;/P&gt;
&lt;P&gt;and so on....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is that the order is not as I want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;case when (X=0 OR X=.) and W&amp;gt;0 then 'a1.Case1'&lt;BR /&gt;when (W=0 OR W=.) and X&amp;gt;0 then 'a2.Case2'&lt;BR /&gt;When (X=0 OR X=.) and (W=0 OR W=.) then 'a3.Case3' &lt;BR /&gt;when calculated Dif1&amp;lt;(-100000) then 'a4.&amp;lt;Lower than -100K'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-100000) AND calculated Dif1&amp;lt;(-50000) then 'a5.[-100,-50)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-50000) AND calculated Dif1&amp;lt;(-40000) then 'a6.[-50,-40)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-40000) AND calculated Dif1&amp;lt;(-30000) then 'a7.[-40,-30)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-30000) AND calculated Dif1&amp;lt;(-20000) then 'a8.[-30,-20)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-20000) AND calculated Dif1&amp;lt;(-15000) then 'a9.[-20,-15)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-15000) AND calculated Dif1&amp;lt;(-10000) then 'a10.[-15,-10)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-10000) and calculated Dif1&amp;lt;(-5000) then 'a11.[-10,-5)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-5000) and calculated Dif1&amp;lt;(-1000) then 'a12.[-5,-1)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-1000) and calculated Dif1&amp;lt;0 then 'a13.[-1,0)'&lt;BR /&gt;end as Ind&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;create table Summary_tbl1 as&lt;BR /&gt;select Ind,&lt;BR /&gt;count(*) as no_customers format=comma18.,&lt;BR /&gt;sum( Dif1)/1000000 as Sum_Dif1_MLS format=comma18.&lt;BR /&gt;from RawData &lt;BR /&gt;group by Ind&lt;BR /&gt;order by Ind&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2019 06:39:03 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2019-08-21T06:39:03Z</dc:date>
    <item>
      <title>order of categories in summary table produced by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582679#M165784</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a problem.&lt;/P&gt;
&lt;P&gt;I use CASE when statement to create a new variable called "IND".&lt;/P&gt;
&lt;P&gt;As you can see I create different groups .&lt;/P&gt;
&lt;P&gt;Later I will calculate summary statistics for each group.&lt;/P&gt;
&lt;P&gt;I want that the order of the groups will be as it appear here:&lt;/P&gt;
&lt;P&gt;'a1.Case1'&lt;/P&gt;
&lt;P&gt;'a2.Case2'&lt;/P&gt;
&lt;P&gt;'a3.Case3'&lt;/P&gt;
&lt;P&gt;'a4.&amp;lt;Lower than -100K'&lt;/P&gt;
&lt;P&gt;'a5.[-100,-50)'&lt;/P&gt;
&lt;P&gt;and so on....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is that the order is not as I want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;case when (X=0 OR X=.) and W&amp;gt;0 then 'a1.Case1'&lt;BR /&gt;when (W=0 OR W=.) and X&amp;gt;0 then 'a2.Case2'&lt;BR /&gt;When (X=0 OR X=.) and (W=0 OR W=.) then 'a3.Case3' &lt;BR /&gt;when calculated Dif1&amp;lt;(-100000) then 'a4.&amp;lt;Lower than -100K'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-100000) AND calculated Dif1&amp;lt;(-50000) then 'a5.[-100,-50)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-50000) AND calculated Dif1&amp;lt;(-40000) then 'a6.[-50,-40)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-40000) AND calculated Dif1&amp;lt;(-30000) then 'a7.[-40,-30)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-30000) AND calculated Dif1&amp;lt;(-20000) then 'a8.[-30,-20)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-20000) AND calculated Dif1&amp;lt;(-15000) then 'a9.[-20,-15)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-15000) AND calculated Dif1&amp;lt;(-10000) then 'a10.[-15,-10)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-10000) and calculated Dif1&amp;lt;(-5000) then 'a11.[-10,-5)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-5000) and calculated Dif1&amp;lt;(-1000) then 'a12.[-5,-1)'&lt;BR /&gt;when calculated Dif1&amp;gt;=(-1000) and calculated Dif1&amp;lt;0 then 'a13.[-1,0)'&lt;BR /&gt;end as Ind&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;create table Summary_tbl1 as&lt;BR /&gt;select Ind,&lt;BR /&gt;count(*) as no_customers format=comma18.,&lt;BR /&gt;sum( Dif1)/1000000 as Sum_Dif1_MLS format=comma18.&lt;BR /&gt;from RawData &lt;BR /&gt;group by Ind&lt;BR /&gt;order by Ind&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 06:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582679#M165784</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-08-21T06:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: order of categories in summary table produced by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582693#M165793</link>
      <description>&lt;P&gt;In the character collating sequence, "a10" comes after "a1" and before "a2". If you will have some two-digit numbers, the one-digit numbers need a leading zero.&lt;/P&gt;
&lt;P&gt;Even better is to use a numeric value in a numeric variable (where 10 automatically follows 9) and apply a display format that contains your human-readable texts.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 07:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582693#M165793</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-21T07:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: order of categories in summary table produced by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582702#M165798</link>
      <description>&lt;P&gt;What is the recommended way to control the order of the groups?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 09:01:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582702#M165798</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-08-21T09:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: order of categories in summary table produced by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582707#M165801</link>
      <description>&lt;P&gt;Both methods can be used, but personally I prefer to use a numeric value with a format. Especially if you do not want the leading zeroes in a report or a graphic meant for human (of the management variety) consumption.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 09:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582707#M165801</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-21T09:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: order of categories in summary table produced by proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582744#M165812</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What is the recommended way to control the order of the groups?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In PROC REPORT you have several ways to control the order of groups, and you don't have to resort to forcing them to be sorted by adding a1 a2 etc to the label. You can have them sort by the underlying data value of variable DIF1. (This is one of many many many benefits of using PROC REPORT instead of PROC SQL to do reporting)&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 12:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/order-of-categories-in-summary-table-produced-by-proc-sql/m-p/582744#M165812</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-21T12:09:30Z</dc:date>
    </item>
  </channel>
</rss>

