<?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 order by total of across variable in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-order-by-total-of-across-variable/m-p/446297#M20631</link>
    <description>Hi:&lt;BR /&gt;  You cannot "sort" on a variable that is used as an analysis variable. However, I had an example of this in my Creating Complex Reports paper, which you will find here. Look on page 10 at Complex example 3: &lt;A href="http://www2.sas.com/proceedings/forum2008/173-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/173-2008.pdf&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;  The report doesn't use ACROSS variables, but the concept is the same, you'll have to make 2 passes one way or another.&lt;BR /&gt;&lt;BR /&gt;  Programs for the 2008 paper are available on the support.sas.com web site, here: &lt;A href="http://support.sas.com/rnd/papers/#SGF2008" target="_blank"&gt;http://support.sas.com/rnd/papers/#SGF2008&lt;/A&gt; and look in the Alpha list for 2008 for the paper title. There's a link to the zip file that has the code that produced the screen shots. You could use PROC MEANS or PROC REPORT or PROC SQL to calculate the totals you want before you run the second PROC REPORT step.&lt;BR /&gt;cynthia</description>
    <pubDate>Fri, 16 Mar 2018 18:01:44 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2018-03-16T18:01:44Z</dc:date>
    <item>
      <title>Proc Report order by total of across variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-order-by-total-of-across-variable/m-p/446220#M20629</link>
      <description>&lt;P&gt;Hello SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am&amp;nbsp;trying to produce a report where I&amp;nbsp;generate columns using an ACROSS variable with a calculated total. Ideally, each row of the report would then be sorted descending by the calculated total. I am having trouble getting this to work as expected, and am thinking it might not be possible. Is there a way to get PROC REPORT to sort by a calculated total variable by groups using ACROSS? When I add ORDER to the DEFINE TOT statement, I get a stairstepping report, which I do not want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below produces an example of the un-sorted report. The report I am looking to generate is exactly this, except I am trying to sort the "Total" column descending by Subsidiary. If this were a PROC SORT the equivalent sort I'd be looking for is:&lt;/P&gt;&lt;P&gt;BY Region descending tot;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.shoes nowd spanrows;
    where Region in ('Africa' 'Asia');
    column ("Summary of Shoes" (Region Subsidiary) (Sales,Product Sales=tot));
        define Region / '' group noprint;
        define Subsidiary / 'Subsidiary' group;
        define Product / across;
        define Sales / analysis mean '';
        define tot / analysis sum 'Total';
    compute before Region / style=[just=l font_style=italic font_weight=bold background=Lightblue foreground=black];
        if Region="Africa" then do;
            text="Africa Region";
        end;
        if Region="Asia" then do;
            text="Asia Region";
        end;
        line text $50.;
    endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;Before I resort to&amp;nbsp;pre-processing the data and then generating the report, I wanted to see if it was indeed not possible to sort&amp;nbsp;in this manner.&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 15:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-order-by-total-of-across-variable/m-p/446220#M20629</guid>
      <dc:creator>bstarr</dc:creator>
      <dc:date>2018-03-16T15:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report order by total of across variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-order-by-total-of-across-variable/m-p/446297#M20631</link>
      <description>Hi:&lt;BR /&gt;  You cannot "sort" on a variable that is used as an analysis variable. However, I had an example of this in my Creating Complex Reports paper, which you will find here. Look on page 10 at Complex example 3: &lt;A href="http://www2.sas.com/proceedings/forum2008/173-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/173-2008.pdf&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;  The report doesn't use ACROSS variables, but the concept is the same, you'll have to make 2 passes one way or another.&lt;BR /&gt;&lt;BR /&gt;  Programs for the 2008 paper are available on the support.sas.com web site, here: &lt;A href="http://support.sas.com/rnd/papers/#SGF2008" target="_blank"&gt;http://support.sas.com/rnd/papers/#SGF2008&lt;/A&gt; and look in the Alpha list for 2008 for the paper title. There's a link to the zip file that has the code that produced the screen shots. You could use PROC MEANS or PROC REPORT or PROC SQL to calculate the totals you want before you run the second PROC REPORT step.&lt;BR /&gt;cynthia</description>
      <pubDate>Fri, 16 Mar 2018 18:01:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-order-by-total-of-across-variable/m-p/446297#M20631</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-03-16T18:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report order by total of across variable</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-order-by-total-of-across-variable/m-p/446304#M20632</link>
      <description>&lt;P&gt;Got it, thank you Cynthia! I will give this a shot.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 18:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Report-order-by-total-of-across-variable/m-p/446304#M20632</guid>
      <dc:creator>bstarr</dc:creator>
      <dc:date>2018-03-16T18:34:30Z</dc:date>
    </item>
  </channel>
</rss>

