<?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: Proc Report ordering in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301304#M17020</link>
    <description>Hi:&lt;BR /&gt;  And, in addition to RW9's description, there are options that you can specify for both ORDER and GROUP items that will further control the order:&lt;BR /&gt;ORDER=DATA (good for pre-sorted rows)&lt;BR /&gt;ORDER=INTERNAL (good for dates)&lt;BR /&gt;ORDER=FORMATTED&lt;BR /&gt;ORDER=FREQ&lt;BR /&gt;&lt;BR /&gt;And to get a column in DESCENDING order, you specify that option on the DEFINE statement, as well.&lt;BR /&gt;&lt;BR /&gt;The COLUMN statement, the DEFINE statement and the usages on the DEFINE statement are very important to understand. For example, it is not appropriate to have both DISPLAY and ORDER on your DEFINE statement -- PROC REPORT will use the last usage you specify -- so if you had reversed the order of the usage option then your DEFINE statement would be broken. Understand the usage (DISPLAY, ORDER, GROUP, ANALYSIS, ACROSS) and specify only 1 usage on a DEFINE statement. The exception to that rule is for numeric variables where this is OK:&lt;BR /&gt;define numvar / analysis sum;&lt;BR /&gt;or&lt;BR /&gt;define numvar2 / analysis mean;&lt;BR /&gt;&lt;BR /&gt;But, in fact, the alternate syntax is fine:&lt;BR /&gt;define numvar / sum;&lt;BR /&gt;define numvar2 / mean;&lt;BR /&gt;&lt;BR /&gt;Here is a documentation example on ordering the rows in PROC REPORT:&lt;BR /&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n1jfpsg4rtte8bn1bg958uj3yfg5.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n1jfpsg4rtte8bn1bg958uj3yfg5.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
    <pubDate>Wed, 28 Sep 2016 14:41:43 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2016-09-28T14:41:43Z</dc:date>
    <item>
      <title>Proc Report ordering</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/300918#M17010</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First time using PROC REPORT and I have not understanding the sort order.&lt;/P&gt;&lt;P&gt;Under PROC SQL it is something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from table1 order by colX asc, colY desc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In PROC REPORT, I guess you use&lt;/P&gt;&lt;P&gt;define colX&amp;nbsp; / display order order=data ;&lt;/P&gt;&lt;P&gt;define colY&amp;nbsp; / display order order=data descending&amp;nbsp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do you asign an overall order to the definition?&amp;nbsp; ie, I need it order by colX first and then colY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I include display data with null values in the order column?&amp;nbsp; Once you put the word order in the define line, the row no longer appears in the output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 04:49:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/300918#M17010</guid>
      <dc:creator>mark_svensson</dc:creator>
      <dc:date>2016-09-27T04:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report ordering</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/300937#M17012</link>
      <description>&lt;P&gt;Hi Mark,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could first of all, do a proc sort by colX and ColY. After that, you could create a new variable order=_N_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doing this you create a non missing variable to order data. adding to columns this variable and a definition like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;define Order /noprint order&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you should see your data as you want.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 07:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/300937#M17012</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2016-09-27T07:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report ordering</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/300957#M17013</link>
      <description>&lt;P&gt;The order of the columns is defined by the columns statement:&lt;/P&gt;
&lt;PRE&gt;proc report...;
  column var1 var2;
  define var1 / order;
  define var2 / order;
run;&lt;/PRE&gt;
&lt;P&gt;In this example the data is sorted by var1 and then var2, you would swap them over by changing the position in the column. &amp;nbsp;Per the documentation. &amp;nbsp;Here is an example:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings11/090-2011.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings11/090-2011.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 08:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/300957#M17013</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-27T08:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report ordering</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301304#M17020</link>
      <description>Hi:&lt;BR /&gt;  And, in addition to RW9's description, there are options that you can specify for both ORDER and GROUP items that will further control the order:&lt;BR /&gt;ORDER=DATA (good for pre-sorted rows)&lt;BR /&gt;ORDER=INTERNAL (good for dates)&lt;BR /&gt;ORDER=FORMATTED&lt;BR /&gt;ORDER=FREQ&lt;BR /&gt;&lt;BR /&gt;And to get a column in DESCENDING order, you specify that option on the DEFINE statement, as well.&lt;BR /&gt;&lt;BR /&gt;The COLUMN statement, the DEFINE statement and the usages on the DEFINE statement are very important to understand. For example, it is not appropriate to have both DISPLAY and ORDER on your DEFINE statement -- PROC REPORT will use the last usage you specify -- so if you had reversed the order of the usage option then your DEFINE statement would be broken. Understand the usage (DISPLAY, ORDER, GROUP, ANALYSIS, ACROSS) and specify only 1 usage on a DEFINE statement. The exception to that rule is for numeric variables where this is OK:&lt;BR /&gt;define numvar / analysis sum;&lt;BR /&gt;or&lt;BR /&gt;define numvar2 / analysis mean;&lt;BR /&gt;&lt;BR /&gt;But, in fact, the alternate syntax is fine:&lt;BR /&gt;define numvar / sum;&lt;BR /&gt;define numvar2 / mean;&lt;BR /&gt;&lt;BR /&gt;Here is a documentation example on ordering the rows in PROC REPORT:&lt;BR /&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n1jfpsg4rtte8bn1bg958uj3yfg5.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n1jfpsg4rtte8bn1bg958uj3yfg5.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Wed, 28 Sep 2016 14:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301304#M17020</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-09-28T14:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report ordering</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301425#M17025</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I was trying to do was to format a pdf output.&amp;nbsp; I was looping though multiple clients and creating five subtables for each client.&amp;nbsp; Each pdf report ran up to 4000 pages.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ended up using proc sql instead.&amp;nbsp; It is much easier to write and&amp;nbsp;once I&amp;nbsp;realised you could give a different class to each table, the pdf now looks very colourful and easy to read.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2016 23:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301425#M17025</guid>
      <dc:creator>mark_svensson</dc:creator>
      <dc:date>2016-09-28T23:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report ordering</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301466#M17026</link>
      <description>&lt;P&gt;In which case by group processing is what you want:&lt;/P&gt;
&lt;PRE&gt;proc report data=...;
  by client subgroup;
  title1 "Client=#byval1";
  title2 "Subgroup=#byval2";
...
run;
&lt;/PRE&gt;
&lt;P&gt;Does all that looping for you. &amp;nbsp;Only time I loop myself is if there are complicated by groupings and such like. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 08:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301466#M17026</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-29T08:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report ordering</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301652#M17033</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you for your reply.&amp;nbsp; I have not used the approach you mentioned, is it possible to write a little more pseudo code for me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;At the moment I am using a macro to loop through the clients&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then I draw data from five separate tables for each client – move to the next client, etc.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The recipients of the report insist each of the five tables have a different format (colour, font) so it is easier for them to delineate.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The whole report ends up as a large pdf.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 21:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-ordering/m-p/301652#M17033</guid>
      <dc:creator>mark_svensson</dc:creator>
      <dc:date>2016-09-29T21:48:14Z</dc:date>
    </item>
  </channel>
</rss>

