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:
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:
Thanks for help.
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;
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;
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;
Thank to both of you very much for the help.
With the different views it was very easy to understand proc tabulate.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.