<?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: Customizing Sort Order in a proc report in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8607#M2871</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. ArtC&lt;/P&gt;&lt;P&gt;Yes, That is a good way too. But I perfer my way ,it is easy and convenient. Excuse me.&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Jun 2011 04:53:01 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-06-28T04:53:01Z</dc:date>
    <item>
      <title>Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8598#M2862</link>
      <description>Hello,&lt;BR /&gt;
I am trying to sort a dataset and display using the proc report in a specific order. &lt;BR /&gt;
&lt;BR /&gt;
Currently it looks like this (alphabetical order in proc report)-&lt;BR /&gt;
Distribution Center &lt;BR /&gt;
Headquarters &lt;BR /&gt;
Retail Store &lt;BR /&gt;
&lt;BR /&gt;
It needs to look like this -&lt;BR /&gt;
HeadQuarters&lt;BR /&gt;
Distribution Centers&lt;BR /&gt;
Retail Stores&lt;BR /&gt;
&lt;BR /&gt;
Please note that it also needs to take care of the difference in the singular/plural words. I have a database which has these values, so a proc sql can extract the 3 values into a dataset.&lt;BR /&gt;
&lt;BR /&gt;
Appreciate any help on this.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
saspert.</description>
      <pubDate>Tue, 07 Jun 2011 15:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8598#M2862</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-06-07T15:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8599#M2863</link>
      <description>Hi:&lt;BR /&gt;
  I can think of 2 possibilities -- if you are certain that the data are in the order you want, then use ORDER=DATA (for your group or order variable). See #1 below.&lt;BR /&gt;
 &lt;BR /&gt;
  On the other hand, if you wanted to be absolutely sure that the data were in your order, you could make an ordering variable (see the variable AR_ORD) and then use that variable in your REPORT syntax. See #2 below.&lt;BR /&gt;
 &lt;BR /&gt;
  With technique #1, the North area is first. With technique #2, the West area is first. For #2, you can use NOPRINT on the DEFINE statement to "hide" the AR_ORD variable from showing on the final output.&lt;BR /&gt;
 &lt;BR /&gt;
  cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data myorder;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input area $ subgrp $ amt;&lt;BR /&gt;
  array tmp{4} $5 _temporary_ ('West' 'South' 'East' 'North');&lt;BR /&gt;
  do i = 1 to 4 by 1;&lt;BR /&gt;
     if tmp(i) = area then ar_ord = i;&lt;BR /&gt;
  end;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
North AA 100&lt;BR /&gt;
South AA 100&lt;BR /&gt;
East  AA 100&lt;BR /&gt;
West  AA 100&lt;BR /&gt;
North AA 100&lt;BR /&gt;
South AA 100&lt;BR /&gt;
East  AA 100&lt;BR /&gt;
West  AA 100&lt;BR /&gt;
North BB 100&lt;BR /&gt;
North BB 100&lt;BR /&gt;
South BB 150&lt;BR /&gt;
South BB 150&lt;BR /&gt;
East AA 175&lt;BR /&gt;
East BB 175&lt;BR /&gt;
West AA 200&lt;BR /&gt;
West BB 200&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                              &lt;BR /&gt;
ods html file='c:\temp\certain_order.html' style=sasweb;&lt;BR /&gt;
proc report data=myorder nowd;&lt;BR /&gt;
  title '1) using ORDER=DATA, North is first';&lt;BR /&gt;
  column area subgrp amt;&lt;BR /&gt;
  define area / group order=data;&lt;BR /&gt;
  define subgrp / group ;&lt;BR /&gt;
  define amt / sum;&lt;BR /&gt;
run;&lt;BR /&gt;
                                                                &lt;BR /&gt;
proc report data=myorder nowd;&lt;BR /&gt;
  title '2) using special variable, West is first';&lt;BR /&gt;
  column ar_ord area subgrp amt;&lt;BR /&gt;
  define ar_ord/ group /* noprint */;&lt;BR /&gt;
  define area / group;&lt;BR /&gt;
  define subgrp / group ;&lt;BR /&gt;
  define amt / sum;&lt;BR /&gt;
run;&lt;BR /&gt;
ods _all_ close;&lt;BR /&gt;
title;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 07 Jun 2011 20:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8599#M2863</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-06-07T20:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8600#M2864</link>
      <description>I will add the third method.&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data myorder;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input department $50.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Distribution Center&lt;BR /&gt;
Headquarters&lt;BR /&gt;
Retail Store &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data myorder;&lt;BR /&gt;
 set myorder;&lt;BR /&gt;
 if department eq 'Headquarters' then department='    '||department;&lt;BR /&gt;
  else  if department eq 'Distribution Center' then department=' '||department;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html file='c:\temp\certain_order.html' style=sasweb;&lt;BR /&gt;
proc report data=myorder nowd ;&lt;BR /&gt;
 column department;&lt;BR /&gt;
 define department/order order=internal;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 08 Jun 2011 08:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8600#M2864</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-08T08:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8601#M2865</link>
      <description>Hi Cynthia,&lt;BR /&gt;
Thank you for your suggestion. Maybe I overanalyzed the problem initially. I seem to have a simple solution for it - just wanted to run it by you and Ksharp.&lt;BR /&gt;
&lt;BR /&gt;
DATA BT_PCT;&lt;BR /&gt;
LENGTH FIRST_LETTER $1;&lt;BR /&gt;
SET BT_PCT;&lt;BR /&gt;
FIRST_LETTER=UPCASE(SUBSTR(TRIM(LEFT(BUILDING_TYPE)),1,1));&lt;BR /&gt;
IF FIRST_LETTER = 'H' THEN BT_SORT_ORDER=1;&lt;BR /&gt;
IF FIRST_LETTER = 'D' THEN BT_SORT_ORDER=2;&lt;BR /&gt;
IF FIRST_LETTER = 'R' THEN BT_SORT_ORDER=3;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc report data=bt_pct;&lt;BR /&gt;
DEFINE BT_SORT_ORDER / GROUP NOPRINT ;&lt;BR /&gt;
define building_type / display;&lt;BR /&gt;
(rest of the code....)&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Any feedback on this?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
saspert.</description>
      <pubDate>Wed, 08 Jun 2011 16:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8601#M2865</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-06-08T16:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8602#M2866</link>
      <description>Thank you Ksharp - could you review my short code and see if there are possible errors?&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
saspert</description>
      <pubDate>Wed, 08 Jun 2011 16:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8602#M2866</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-06-08T16:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8603#M2867</link>
      <description>Hi:&lt;BR /&gt;
 Your BT_SORT_ORDER variable is like my AR_ORD variable and #2 example. The only difference is that I used an ARRAY to do the lookup and put WEST first and you are using the first letter of your BUILDING_TYPE variable to create the ordering variable.&lt;BR /&gt;
&lt;BR /&gt;
  I tend not to use the leading spaces trick (you can't always be certain that the leading spaces will be respected in all destinations)or the ORDER=DATA trick (the data might not be in the order you want and it might be hard to sort the data to get the order you want). So, I prefer to create an ordering variable that will set the order, but I can hide it with the NOPRINT option.&lt;BR /&gt;
&lt;BR /&gt;
  You have to maintain the code. So you should go with the technique that makes the most sense to you.  BTW, if BT_SORT_ORDER is GROUP usage and BUILDING_TYPE is DISPLAY usage, you may as well just change BT_SORT_ORDER to ORDER usage -- because you should be seeing a note in the log to that effect:&lt;BR /&gt;
[pre]&lt;BR /&gt;
NOTE: Groups are not created because the usage of BUILDING_TYPE is&lt;BR /&gt;
DISPLAY. To avoid this note, change all GROUP variables to&lt;BR /&gt;
ORDER variables.&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                    &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 08 Jun 2011 18:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8603#M2867</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-06-08T18:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8604#M2868</link>
      <description>Hi saspert,&lt;BR /&gt;
&lt;BR /&gt;
There is another example, using formats and order=internal, that I posted in response to your question on runsubmit.com: &lt;A href="http://www.runsubmit.com/questions/592/customized-sorting-in-proc-report" target="_blank"&gt;http://www.runsubmit.com/questions/592/customized-sorting-in-proc-report&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers&lt;BR /&gt;
Paul</description>
      <pubDate>Wed, 08 Jun 2011 22:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8604#M2868</guid>
      <dc:creator>PaulHomes</dc:creator>
      <dc:date>2011-06-08T22:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8605#M2869</link>
      <description>I did not found problem.&lt;BR /&gt;
But You can shorten your code like:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
IF FIRST_LETTER eq: 'H' THEN BT_SORT_ORDER=1;&lt;BR /&gt;
IF FIRST_LETTER eq: 'D' THEN BT_SORT_ORDER=2;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 09 Jun 2011 02:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8605#M2869</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-09T02:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8606#M2870</link>
      <description>The NOTSORTED option can be used when building a format.  This allows you to have the advantage of a format, but maintain the order of the formats definition.&lt;BR /&gt;
&lt;BR /&gt;
This can be very useful when trying to both control order and format a column.  It can also avoid the need to create an ordering variable.</description>
      <pubDate>Wed, 15 Jun 2011 05:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8606#M2870</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-06-15T05:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Customizing Sort Order in a proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8607#M2871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. ArtC&lt;/P&gt;&lt;P&gt;Yes, That is a good way too. But I perfer my way ,it is easy and convenient. Excuse me.&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jun 2011 04:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Customizing-Sort-Order-in-a-proc-report/m-p/8607#M2871</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-28T04:53:01Z</dc:date>
    </item>
  </channel>
</rss>

