BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
meatmuffin
Calcite | Level 5


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.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ


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

3 REPLIES 3
Kathryn_SAS
SAS Employee

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;

Cynthia_sas
SAS Super FREQ


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;

meatmuffin
Calcite | Level 5

Thank to both of you very much for the help.

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


sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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