<?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 sort by second column, then first column in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-REPORT-sort-by-second-column-then-first-column/m-p/757941#M80826</link>
    <description>Hi:&lt;BR /&gt;  Without data, no one can run or tweak your code. When PROC REPORT does ordering, it orders the items from left to right (the same as PROC SORT). So when you list VAR first and then TIME, the result is that the report is ordered by TIME within VAR. If you want the order to be different you have to switch the order of VAR and TIME in the COLUMN statement so that TIME is first. &lt;BR /&gt;Cynthia</description>
    <pubDate>Wed, 28 Jul 2021 20:30:36 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2021-07-28T20:30:36Z</dc:date>
    <item>
      <title>PROC REPORT sort by second column, then first column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-REPORT-sort-by-second-column-then-first-column/m-p/757925#M80824</link>
      <description>&lt;P&gt;I am new to using PROC REPORT and do not fully understand how the sorting works. My code is as follows (substituted with dummy variables):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data = working nowd split = '*'
 %reportStyle;

 column VAR TIME _STAT_ CAT1 CAT2 CAT3;

 define VAR / order 'Variable' order = data style(column) = [just = left cellwidth = 0.7in];
 define TIME / order 'Subvariable' order = data style(column) =...;
 define _STAT_ / display 'Statistics' format = stat. style(column) = ...;
 define CAT1 / display 'CAT1' ...;
 define CAT2 / display 'CAT2' ...;
 define CAT3 / display 'CAT3' ...;

 compute after;
  line "Footnote";
 endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want it to first sort by Subvariable and then by Variable, while maintaining my desired order of columns.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mariko5797_4-1627501929750.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62032i1B7C16692DDDA639/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mariko5797_4-1627501929750.png" alt="mariko5797_4-1627501929750.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mariko5797_2-1627501864555.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62030i43C2CC14673B6772/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mariko5797_2-1627501864555.png" alt="mariko5797_2-1627501864555.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 19:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-REPORT-sort-by-second-column-then-first-column/m-p/757925#M80824</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2021-07-28T19:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT sort by second column, then first column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-REPORT-sort-by-second-column-then-first-column/m-p/757935#M80825</link>
      <description>&lt;P&gt;Introduce an extra copy of the second column as a hidden zero-th column to sort by.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.class ;
  column sex=extra name sex age ;
  define extra / order noprint;
  define name / order ;
  define sex / order;
  define age / display;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 20:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-REPORT-sort-by-second-column-then-first-column/m-p/757935#M80825</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-28T20:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT sort by second column, then first column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-REPORT-sort-by-second-column-then-first-column/m-p/757941#M80826</link>
      <description>Hi:&lt;BR /&gt;  Without data, no one can run or tweak your code. When PROC REPORT does ordering, it orders the items from left to right (the same as PROC SORT). So when you list VAR first and then TIME, the result is that the report is ordered by TIME within VAR. If you want the order to be different you have to switch the order of VAR and TIME in the COLUMN statement so that TIME is first. &lt;BR /&gt;Cynthia</description>
      <pubDate>Wed, 28 Jul 2021 20:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-REPORT-sort-by-second-column-then-first-column/m-p/757941#M80826</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-07-28T20:30:36Z</dc:date>
    </item>
  </channel>
</rss>

