<?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 month sorting issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553755#M154012</link>
    <description>&lt;P&gt;Don't even need a month number variable the original SETUP_date works just fine with the proper format and order option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data = mydata nowd style(summary)=Header;
column year2 &lt;STRONG&gt;setup_date&lt;/STRONG&gt; cnt rtot;
define year2 /group ;
define &lt;STRONG&gt;setup_date&lt;/STRONG&gt; /group f=monname3. order=internal ;
define cnt /sum f=comma6.;
define RTot /computed f=comma16. "Row Totals";
compute RTot; 
RTot=sum(cnt.sum);/*row_tot*/
endcomp;
compute before;
 
sum=cnt.sum;
endcomp;
compute after;
 year2='Grand Total';
endcomp;
break after year2 / ol summarize skip;/*total by group*/
rbreak after /summarize;
run;
&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Apr 2019 19:15:56 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-04-24T19:15:56Z</dc:date>
    <item>
      <title>proc report month sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553705#M153997</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;infile&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; setup_date &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Division $ cnt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;return&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1Jun2018 Central 4&lt;/P&gt;
&lt;P&gt;1May2018 Central 5&lt;/P&gt;
&lt;P&gt;1Apr2019 Atlantic 3&lt;/P&gt;
&lt;P&gt;1Feb2019 Atlantic 11&lt;/P&gt;
&lt;P&gt;1Jan2017 Pacific 11&lt;/P&gt;
&lt;P&gt;1Mar2019 Central 11&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; setup_date &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*mydata is the data i start with (queried from the database)&lt;/P&gt;
&lt;P&gt;I am just showing test1 and 2 because this is a created example*/&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mydata;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;year1 = year(setup_date);&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*returns numeric*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;year2 = put(year1,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*change to character*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Month1 = put(setup_date,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;monname3.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*change to character*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;report&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = mydata &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;nowd&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;style&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(summary)=Header;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;column&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; year2 Month1 cnt rtot;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;define&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; year2 /&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;define&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Month1 /&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;define&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; cnt /&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;sum&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;f&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;comma6.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;define&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; RTot /&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;computed&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;f&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;comma16.&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;"Row Totals"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;compute&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; RTot; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;RTot=sum(cnt.sum);&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*row_tot*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;endcomp&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;compute&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;before&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sum=cnt.sum;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;endcomp&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;compute&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;after&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; year2=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Grand Total'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;endcomp&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;break&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;after&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; year2 / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;ol&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;summarize&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;skip&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*total by group*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;rbreak&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;after&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; /&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;summarize&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*if you run the code the year2 is in correct order however the month is in alpha order and not by month&lt;/P&gt;
&lt;P&gt;How can I fix this?*/&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 16:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553705#M153997</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2019-04-24T16:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: proc report month sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553731#M154002</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The character variable for month is sorting as I would expect. Consider these changes to your code:&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="sort_month.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/28998i62E1764EF327BB07/image-size/large?v=v2&amp;amp;px=999" role="button" title="sort_month.png" alt="sort_month.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which produces the correct order for MONTH1:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="results_order.png" style="width: 312px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/28999iBD0E4F12E341CA00/image-size/large?v=v2&amp;amp;px=999" role="button" title="results_order.png" alt="results_order.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but only because the MONTHNUM variable is added to the report as a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 17:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553731#M154002</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-04-24T17:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc report month sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553755#M154012</link>
      <description>&lt;P&gt;Don't even need a month number variable the original SETUP_date works just fine with the proper format and order option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data = mydata nowd style(summary)=Header;
column year2 &lt;STRONG&gt;setup_date&lt;/STRONG&gt; cnt rtot;
define year2 /group ;
define &lt;STRONG&gt;setup_date&lt;/STRONG&gt; /group f=monname3. order=internal ;
define cnt /sum f=comma6.;
define RTot /computed f=comma16. "Row Totals";
compute RTot; 
RTot=sum(cnt.sum);/*row_tot*/
endcomp;
compute before;
 
sum=cnt.sum;
endcomp;
compute after;
 year2='Grand Total';
endcomp;
break after year2 / ol summarize skip;/*total by group*/
rbreak after /summarize;
run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Apr 2019 19:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553755#M154012</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-24T19:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc report month sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553808#M154028</link>
      <description>Clever approach! I figured the original poster had some other need for character variables. The way they were calculating totals was a bit odd too and not the say I would have done that part of the report either.&lt;BR /&gt;Cynthia</description>
      <pubDate>Wed, 24 Apr 2019 23:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553808#M154028</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-04-24T23:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc report month sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553810#M154030</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Clever approach! I figured the original poster had some other need for character variables. The way they were calculating totals was a bit odd too and not the say I would have done that part of the report either.&lt;BR /&gt;Cynthia&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I didn't bother to look at the body for the other columns, just enough to see that my values matched yours.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just wanted to emphasize the date + format is a powerful grouping tool.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 23:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-month-sorting-issue/m-p/553810#M154030</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-24T23:14:02Z</dc:date>
    </item>
  </channel>
</rss>

