Help using Base SAS procedures

help: proc tabulate

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

help: proc tabulate


Hello,

I'm trying to generate a table with proc tabulate but now i'm having some problems to insert "dummy" rowtitles. 

My table looks like the following example:

proc_tabulate.PNG

Created by the following code:

*******

PROC TABULATE
DATA= mydata
;

VAR SUM_A_KOST_J SUM_VORHABEN SUM_TOTAL_VORHABEN SUM_VORHABEN_OEFFENTLICH SUM_TOTAL_AUSGABEN SUM_AUSGABEN_OEFFENTLICH;
CLASS PERH_J / ORDER=UNFORMATTED MISSING;
CLASS A_TYPARB / ORDER=UNFORMATTED MISSING;
TABLE /* Zeilendimension */
PERH_J={LABEL=''},
/* Spaltendimension */
SUM_TOTAL_AUSGABEN*
  Sum={LABEL=''}
SUM_TOTAL_VORHABEN*
  Sum={LABEL=''}
A_TYPARB={LABEL=''}*(
  SUM_A_KOST_J*
    Sum={LABEL=''}
  SUM_VORHABEN*
    Sum={LABEL=''})
SUM_AUSGABEN_OEFFENTLICH*
  Sum={LABEL=''}
SUM_VORHABEN_OEFFENTLICH*
  Sum={LABEL=''}   ;
;

RUN;

********

Now i would like to insert a cell above the first two titles (SUM_TOTAL_AUSGABEN SUM_TOTAL_VORHABEN) at the same height as the numbers 4 and 5. Furthermore the cell should be combined like number 4 or number 5.

The same should be done for the last two rows.

it should look like the following:

proc_tabulate.PNG

Thanks for help.


Accepted Solutions
Solution
‎01-31-2013 09:58 AM
SAS Super FREQ
Posts: 8,864

Re: help: proc tabulate

Posted in reply to meatmuffin


Hi:

  Try running the code below and see if that helps you understand how TABULATE builds headers. You can only attach a header in TABULATE to a CLASS, VAR or STATISTIC name. In PROC REPORT, you can put arbitrary spanning headers. Consider the code below.

cynthia

ods html file='c:\temp\header_tab.html';

 

proc tabulate data=sashelp.class;

  where age ge 14;

  class age sex;

  var height weight;

  table age,

        height*sum="Under" weight*sum="Under" sex*n='under'

        /box='1) Under';

 

  table age,

        sum="over"*height sum="over"*weight n='spanned'*sex

        /box='2) Over';

 

  table age,

        sum="spanned"*(height weight) n=' '*sex

        /box='3) Spanned';

run;

  

proc report data=sashelp.class nowd;

  title '4) PROC REPORT Spanning Headers';

  column ('Top Header' age ("More Over" sum,(height weight) sex));

  define age / group;

  define height / analysis;

  define weight / analysis;

  define sum / 'Over';

  define sex / across;

run;

ods html close;

View solution in original post


All Replies
SAS Employee
Posts: 22

Re: help: proc tabulate

Posted in reply to meatmuffin

You can use the SUM= statistic to create the label to span multiple analysis variables.  I have included an example below:

proc tabulate data=sashelp.class;

class age sex;

var height weight;

table age, sum='total expenditure'*(height weight)

sex=' '*(height weight)*sum=' ';

run;

Solution
‎01-31-2013 09:58 AM
SAS Super FREQ
Posts: 8,864

Re: help: proc tabulate

Posted in reply to meatmuffin


Hi:

  Try running the code below and see if that helps you understand how TABULATE builds headers. You can only attach a header in TABULATE to a CLASS, VAR or STATISTIC name. In PROC REPORT, you can put arbitrary spanning headers. Consider the code below.

cynthia

ods html file='c:\temp\header_tab.html';

 

proc tabulate data=sashelp.class;

  where age ge 14;

  class age sex;

  var height weight;

  table age,

        height*sum="Under" weight*sum="Under" sex*n='under'

        /box='1) Under';

 

  table age,

        sum="over"*height sum="over"*weight n='spanned'*sex

        /box='2) Over';

 

  table age,

        sum="spanned"*(height weight) n=' '*sex

        /box='3) Spanned';

run;

  

proc report data=sashelp.class nowd;

  title '4) PROC REPORT Spanning Headers';

  column ('Top Header' age ("More Over" sum,(height weight) sex));

  define age / group;

  define height / analysis;

  define weight / analysis;

  define sum / 'Over';

  define sex / across;

run;

ods html close;

Occasional Contributor
Posts: 6

Re: help: proc tabulate

Posted in reply to Cynthia_sas

Thank to both of you very much for the help.

With the different views it was very easy to understand proc tabulate.


🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 332 views
  • 3 likes
  • 3 in conversation