<?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 - not totaling and not sorting correctly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-not-totaling-and-not-sorting-correctly/m-p/613463#M179157</link>
    <description>&lt;P&gt;Try replacing both monthsum and month1 with setup_date defined as an across column with order=internal and format monyy5:&lt;/P&gt;
&lt;PRE&gt;define setup_date / across order = internal format = monyy5.;&lt;/PRE&gt;</description>
    <pubDate>Sun, 22 Dec 2019 23:21:40 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2019-12-22T23:21:40Z</dc:date>
    <item>
      <title>proc report - not totaling and not sorting correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-not-totaling-and-not-sorting-correctly/m-p/613459#M179155</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; have;&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; Type $ 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;1jun2019 Central 1&lt;/P&gt;
&lt;P&gt;1jun2019 West 1&lt;/P&gt;
&lt;P&gt;12jul2019 East 1&lt;/P&gt;
&lt;P&gt;14aug2019 West 1&lt;/P&gt;
&lt;P&gt;15aug2019 West 1&lt;/P&gt;
&lt;P&gt;20aug2019 East 1&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&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; have2;&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; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;monthsum = month(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;Month1 = put(setup_date,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;monyy5.&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="#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="#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;&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;=have2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;wrap&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;(column)={just=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;center&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;column&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Type monthsum MONTH1 cnt ;&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; Type / &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&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; (column)=[cellwidth=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;pt] &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"EXC TYPE"&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; monthsum /&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;noprint&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;order&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; = internal; &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;across&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;(column)=[cellwidth=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;pt] &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"MONTH"&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="#800080" face="Courier New" size="3"&gt;"Row Total"&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;(column)=[cellwidth=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;90&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;pt];&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 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;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;Type = &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="#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;&lt;FONT face="Courier New" size="3"&gt;Issue#1 -&amp;nbsp; The proc report appears not to roll up totals correctly.&amp;nbsp; I get extra rows in the output&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Issue#2 - The Month1 (across) is not sorting by month despite using the monthsum.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 23:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-not-totaling-and-not-sorting-correctly/m-p/613459#M179155</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2019-12-22T23:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc report - not totaling and not sorting correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-not-totaling-and-not-sorting-correctly/m-p/613463#M179157</link>
      <description>&lt;P&gt;Try replacing both monthsum and month1 with setup_date defined as an across column with order=internal and format monyy5:&lt;/P&gt;
&lt;PRE&gt;define setup_date / across order = internal format = monyy5.;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Dec 2019 23:21:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-not-totaling-and-not-sorting-correctly/m-p/613463#M179157</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-12-22T23:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: proc report - not totaling and not sorting correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-not-totaling-and-not-sorting-correctly/m-p/613465#M179158</link>
      <description>&lt;P&gt;What do you want out.&amp;nbsp; Might be easiest to just make a date value that is the first of the month using the INTNX() function to use for your ACROSS variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input setup_date :date9. Type :$11. cnt;
  format setup_date date9.;
datalines;
1jun2019 Central 1
1jun2019 West 1
12jul2019 East 1
14aug2019 West 1
15aug2019 West 1
20aug2019 East 1
;

proc print data=have; title 'HAVE'; run;

data have2;
  set have;
  Month2 = intnx('month',setup_date,0,'b');
  format month2 monyy7. ;
run;
proc print data=have2; title 'HAVE2'; run;

proc report data=have2 wrap style(column)={just=center};
title 'PROC REPORT';
  column Type cnt,month2 ;
  define Type / group style (column)=[cellwidth=100pt] "EXC TYPE";
  define MONTH2 /across order=internal style(column)=[cellwidth=100pt] "MONTH";
  define cnt / sum ' ' style(column)=[cellwidth=90pt];
  rbreak after / summarize style (summary)= Header;
  compute after;
    Type = 'Grand Total';
  endcomp;
run;
title;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35006i865D06060CE030B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 23:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-not-totaling-and-not-sorting-correctly/m-p/613465#M179158</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-22T23:33:06Z</dc:date>
    </item>
  </channel>
</rss>

