<?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: tabulate not printing the table output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926722#M364697</link>
    <description>&lt;P&gt;You could try PROC REPORT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input category $ month $ value;
datalines;
a jan 100
a feb 150
b jan 130
b feb 300
c jan 11
c feb 23
c mar 26
;
proc report data=have nowd out=want;
column category  month,value all;
define category/group;
define month/across '';
define value/analysis '';
define all/computed;
compute all;
all=sum(_c2_,_c3_,_c4_);
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1714621525244.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96121iD1DB94549B219927/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1714621525244.png" alt="Ksharp_0-1714621525244.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 May 2024 03:45:47 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-05-02T03:45:47Z</dc:date>
    <item>
      <title>tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926653#M364670</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wfc_0-1714584307891.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96096i071ED956ADDBE106/image-size/medium?v=v2&amp;amp;px=400" role="button" title="wfc_0-1714584307891.png" alt="wfc_0-1714584307891.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want the ouput to have the first table which is pivot.. but after i run its printing the output as the second table but not the pivot which i am expecting&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 17:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926653#M364670</guid>
      <dc:creator>wfc</dc:creator>
      <dc:date>2024-05-01T17:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926663#M364673</link>
      <description>&lt;P&gt;The output table has the data you asked for, just not in the format you want. You need to transpose the data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=test;
	by month;
run;

proc transpose data=test out=test1(drop=_:);
  by month;
  id category;
  var value_sum;
run;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.TEST1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;month&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;a&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;b&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;c&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="r data"&gt;250&lt;/TD&gt;
&lt;TD class="r data"&gt;430&lt;/TD&gt;
&lt;TD class="r data"&gt;57&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="l data"&gt;feb&lt;/TD&gt;
&lt;TD class="r data"&gt;150&lt;/TD&gt;
&lt;TD class="r data"&gt;300&lt;/TD&gt;
&lt;TD class="r data"&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="l data"&gt;jan&lt;/TD&gt;
&lt;TD class="r data"&gt;100&lt;/TD&gt;
&lt;TD class="r data"&gt;130&lt;/TD&gt;
&lt;TD class="r data"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;4&lt;/TH&gt;
&lt;TD class="l data"&gt;mar&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 01 May 2024 18:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926663#M364673</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-05-01T18:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926664#M364674</link>
      <description>&lt;P&gt;i want the output exactly as i showed in the above . The solution will not work for me.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 18:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926664#M364674</guid>
      <dc:creator>wfc</dc:creator>
      <dc:date>2024-05-01T18:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926674#M364678</link>
      <description>There isn't a procedure that automatically does that. &lt;BR /&gt;&lt;BR /&gt;To get the end results, pivot and sum in a data step or you can pivot the proc tabulate. &lt;BR /&gt;&lt;BR /&gt;Note that there is no two level headings as in the picture so you only get a single column heading. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 May 2024 19:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926674#M364678</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-05-01T19:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926676#M364679</link>
      <description>&lt;P&gt;can you please guide me on how to do that, i am a newbie at SAS. i dont require 2 level heading, even one level which shows the month should work for me. can you please provide the syntax on acheving the same?&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 19:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926676#M364679</guid>
      <dc:creator>wfc</dc:creator>
      <dc:date>2024-05-01T19:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926678#M364680</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/465667"&gt;@wfc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i want the output exactly as i showed in the above . The solution will not work for me.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does that mean?&amp;nbsp; A dataset and a report are two totally different things.&amp;nbsp; A dataset cannot have variable names that look like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1714591062838.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96109i6126C73246915C1D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1714591062838.png" alt="Tom_0-1714591062838.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you should just use ODS EXCEL to route your report to a spreadsheet?&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 19:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926678#M364680</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-01T19:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926680#M364681</link>
      <description>&lt;P&gt;For more help share your program as text, not a photograph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the Insert SAS Code button to get a pop-up window where you can paste/edit the SAS code so that the forum does not treat it as paragraphs.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 19:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926680#M364681</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-01T19:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926681#M364682</link>
      <description>&lt;P&gt;data have; input category $ month $ value; datalines; a jan 100 a feb 150 b jan 130 b feb 300 c jan 11 c feb 23 c mar 26 ; ods output table=tabulate_results; proc tabulate data=have ; class category month; var value; Table category, (month all='Total')*(value='')*(sum=''); quit; proc print data=tabulate_results; run;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 19:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926681#M364682</guid>
      <dc:creator>wfc</dc:creator>
      <dc:date>2024-05-01T19:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926684#M364683</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/465667"&gt;@wfc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;data have; input category $ month $ value; datalines; a jan 100 a feb 150 b jan 130 b feb 300 c jan 11 c feb 23 c mar 26 ; ods output table=tabulate_results; proc tabulate data=have ; class category month; var value; Table category, (month all='Total')*(value='')*(sum=''); quit; proc print data=tabulate_results; run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See what happens when you give the forum code as if it was your comments?&lt;/P&gt;
&lt;P&gt;Let's reformat that so it is readable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input category $ month $ value;
datalines;
a jan 100
a feb 150
b jan 130
b feb 300
c jan 11
c feb 23
c mar 26
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since your two class variables are character you can simply use something like this to get the SUM , TRANSPOSE and then add the TOTAL variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
  class category month ;
  var value;
  output out=summary sum=;
run;

proc transpose data=summary out=wide(drop=_name_) ;
  by category ;
  id month; 
  var value;
run;

data want;
  set wide;
  total=sum(of _numeric_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    category    feb    jan    mar    total

 1        a        150    100      .     250
 2        b        300    130      .     430
 3        c         23     11     26      60
&lt;/PRE&gt;
&lt;P&gt;If CATGORY was numeric you would have to account for that in the step that makes the TOTAL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;total=sum(of _numeric_, -category);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If MONTH was numeric you might need to add the PREFIX= option to the PROC TABULATE statement so that the generated variable names will start with a letter.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 20:01:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926684#M364683</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-01T20:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926689#M364686</link>
      <description>&lt;P&gt;Very slight modification on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;correct solution.&lt;/P&gt;
&lt;P&gt;Use a prefix for the month when you transpose and the IDLABEL option to get the correct labels. This way when summing the variables you can refer to them with the known prefix to avoid any other variables getting included.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=summary out=wide(drop=_name_) prefix=month_;
  by category ;
  id month; 
  idlabel month;
  var value;
run;

data want;
  set wide;
  total=sum(of month_:);
run;

proc print data=want label noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2024 20:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926689#M364686</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-05-01T20:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: tabulate not printing the table output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926722#M364697</link>
      <description>&lt;P&gt;You could try PROC REPORT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input category $ month $ value;
datalines;
a jan 100
a feb 150
b jan 130
b feb 300
c jan 11
c feb 23
c mar 26
;
proc report data=have nowd out=want;
column category  month,value all;
define category/group;
define month/across '';
define value/analysis '';
define all/computed;
compute all;
all=sum(_c2_,_c3_,_c4_);
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1714621525244.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96121iD1DB94549B219927/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1714621525244.png" alt="Ksharp_0-1714621525244.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 03:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/tabulate-not-printing-the-table-output/m-p/926722#M364697</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-05-02T03:45:47Z</dc:date>
    </item>
  </channel>
</rss>

