<?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 Sort Across values the way I want it in proc report in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Sort-Across-values-the-way-I-want-it-in-proc-report/m-p/16361#M2986</link>
    <description>Hi there!&lt;BR /&gt;
&lt;BR /&gt;
I have a proc report with an across. I'd like the across values to appear in a certain order which is not alpabetical and not like the values appear in the data set.&lt;BR /&gt;
&lt;BR /&gt;
For a group variable this would be easy because then I would create another group variable 1,2,3,4... with noprint in the define statement and so my grouping variable would habe the order I want. Yet with across that's not so easy because I didn't find a way with a norpint across variable to do this. Maybe I cannot figure out how to do this in the column statement. Stacking for example doesnt work:&lt;BR /&gt;
&lt;BR /&gt;
column var1 myvalue myacrossnoprint, myacross&lt;BR /&gt;
&lt;BR /&gt;
define var1 / group....;&lt;BR /&gt;
define myvalue / analysis sum...;&lt;BR /&gt;
define myacrossnoprint / across noprint ....;&lt;BR /&gt;
define myacross / across...;&lt;BR /&gt;
&lt;BR /&gt;
Does anybody know whether I could solve the task in this way? Or is that way impossible?&lt;BR /&gt;
&lt;BR /&gt;
I tried another way: I defined a notsorted format:&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $myformat (notsorted)&lt;BR /&gt;
       'z' = 'a'&lt;BR /&gt;
      'a' = 'b'&lt;BR /&gt;
      'm' = 'c'&lt;BR /&gt;
       ...... ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
And assigened it like this to the across variable:&lt;BR /&gt;
&lt;BR /&gt;
column var1 myvalue myacross&lt;BR /&gt;
&lt;BR /&gt;
define var1 / group....;&lt;BR /&gt;
define myvalue / analysis sum...;&lt;BR /&gt;
define myacross / across preloadfmt order=data format=$myformat...;&lt;BR /&gt;
&lt;BR /&gt;
That's great but then all the values written down in the format ar shown even if there is no datarow for it in the data. Now what I'd like to have is that the order defined in the format is kept in the across and that only the values that appear on the dataset are used and displayed. Is that possible?&lt;BR /&gt;
&lt;BR /&gt;
Best regards&lt;BR /&gt;
Eva</description>
    <pubDate>Wed, 08 Apr 2009 08:55:49 GMT</pubDate>
    <dc:creator>Eva</dc:creator>
    <dc:date>2009-04-08T08:55:49Z</dc:date>
    <item>
      <title>Sort Across values the way I want it in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sort-Across-values-the-way-I-want-it-in-proc-report/m-p/16361#M2986</link>
      <description>Hi there!&lt;BR /&gt;
&lt;BR /&gt;
I have a proc report with an across. I'd like the across values to appear in a certain order which is not alpabetical and not like the values appear in the data set.&lt;BR /&gt;
&lt;BR /&gt;
For a group variable this would be easy because then I would create another group variable 1,2,3,4... with noprint in the define statement and so my grouping variable would habe the order I want. Yet with across that's not so easy because I didn't find a way with a norpint across variable to do this. Maybe I cannot figure out how to do this in the column statement. Stacking for example doesnt work:&lt;BR /&gt;
&lt;BR /&gt;
column var1 myvalue myacrossnoprint, myacross&lt;BR /&gt;
&lt;BR /&gt;
define var1 / group....;&lt;BR /&gt;
define myvalue / analysis sum...;&lt;BR /&gt;
define myacrossnoprint / across noprint ....;&lt;BR /&gt;
define myacross / across...;&lt;BR /&gt;
&lt;BR /&gt;
Does anybody know whether I could solve the task in this way? Or is that way impossible?&lt;BR /&gt;
&lt;BR /&gt;
I tried another way: I defined a notsorted format:&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $myformat (notsorted)&lt;BR /&gt;
       'z' = 'a'&lt;BR /&gt;
      'a' = 'b'&lt;BR /&gt;
      'm' = 'c'&lt;BR /&gt;
       ...... ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
And assigened it like this to the across variable:&lt;BR /&gt;
&lt;BR /&gt;
column var1 myvalue myacross&lt;BR /&gt;
&lt;BR /&gt;
define var1 / group....;&lt;BR /&gt;
define myvalue / analysis sum...;&lt;BR /&gt;
define myacross / across preloadfmt order=data format=$myformat...;&lt;BR /&gt;
&lt;BR /&gt;
That's great but then all the values written down in the format ar shown even if there is no datarow for it in the data. Now what I'd like to have is that the order defined in the format is kept in the across and that only the values that appear on the dataset are used and displayed. Is that possible?&lt;BR /&gt;
&lt;BR /&gt;
Best regards&lt;BR /&gt;
Eva</description>
      <pubDate>Wed, 08 Apr 2009 08:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sort-Across-values-the-way-I-want-it-in-proc-report/m-p/16361#M2986</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2009-04-08T08:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Across values the way I want it in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sort-Across-values-the-way-I-want-it-in-proc-report/m-p/16362#M2987</link>
      <description>Hi:&lt;BR /&gt;
  When you use PRELOADFMT with a user-defined format, you are essentially asking PROC REPORT to behave as you described -- it will use the format to put all the -possible- values on the report, whether data exists for that particular group or order or across variable or not.&lt;BR /&gt;
&lt;BR /&gt;
  Another approach might be to use ORDER=DATA -- which respects the internal order of the data. This means that you would have to sort the data by your desired order before the PROC REPORT step. The quickest way to do this is make a temporary data set with a variable to ensure the order. Sort of like your idea with NOPRINT, only you're using PROC SORT to presort in your desired order. Test program and Listing output below (using SASHELP.SHOES).&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data shoes;&lt;BR /&gt;
  set sashelp.shoes;&lt;BR /&gt;
  where region in ('Asia', 'Canada', 'Pacific', 'Western Europe');&lt;BR /&gt;
  if region = 'Pacific' then accord=1;&lt;BR /&gt;
  else if region = 'Asia' then accord=2;&lt;BR /&gt;
  else if region = 'Western Europe' then accord=3;&lt;BR /&gt;
  else accord=4;&lt;BR /&gt;
run;&lt;BR /&gt;
                  &lt;BR /&gt;
proc sort data=shoes;&lt;BR /&gt;
by accord region product;&lt;BR /&gt;
run;&lt;BR /&gt;
                 &lt;BR /&gt;
options nocenter nodate nonumber;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
ods html file='c:\temp\ord_across.html' style=sasweb;&lt;BR /&gt;
proc report data=shoes nowd;&lt;BR /&gt;
  title '1) Using ORDER=DATA';&lt;BR /&gt;
  column product sales,region sales=stot;&lt;BR /&gt;
  define product / group;&lt;BR /&gt;
  define region / across order=data ;&lt;BR /&gt;
  define sales / sum ' ';&lt;BR /&gt;
  define stot / 'All Regions Total';&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
         &lt;BR /&gt;
************************* OUTPUT ************&lt;BR /&gt;
1) Using ORDER=DATA&lt;BR /&gt;
                                                    &lt;BR /&gt;
  &lt;BR /&gt;
                                          Region&lt;BR /&gt;
                                                   Western                 All Regions&lt;BR /&gt;
  Product              Pacific          Asia        Europe        Canada         Total&lt;BR /&gt;
  Boot                $123,575       $62,708      $296,031      $385,613      $867,927&lt;BR /&gt;
  Men's Casual        $662,368       $11,754      $946,248      $441,903    $2,062,273&lt;BR /&gt;
  Men's Dress         $426,191      $119,366      $747,918      $920,101    $2,213,576&lt;BR /&gt;
  Sandal               $48,424        $8,208       $11,349       $14,798       $82,779&lt;BR /&gt;
  Slipper             $390,740      $152,032      $857,298      $952,751    $2,352,821&lt;BR /&gt;
  Sport Shoe           $26,169        $2,092      $201,030      $140,389      $369,680&lt;BR /&gt;
  Women's Casual      $219,886       $25,837      $985,647      $410,807    $1,642,177&lt;BR /&gt;
  Women's Dress       $399,441       $78,234      $827,479      $989,350    $2,294,504&lt;BR /&gt;
                    $2,296,794      $460,231    $4,873,000    $4,255,712   $11,885,737&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 08 Apr 2009 15:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sort-Across-values-the-way-I-want-it-in-proc-report/m-p/16362#M2987</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-04-08T15:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Sort Across values the way I want it in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sort-Across-values-the-way-I-want-it-in-proc-report/m-p/16363#M2988</link>
      <description>Hello Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
thanx for your reply. That works well!&lt;BR /&gt;
&lt;BR /&gt;
Best regards,&lt;BR /&gt;
Eva</description>
      <pubDate>Thu, 23 Apr 2009 15:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sort-Across-values-the-way-I-want-it-in-proc-report/m-p/16363#M2988</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2009-04-23T15:27:28Z</dc:date>
    </item>
  </channel>
</rss>

