PROC TABULATE DATA=dataset FORMAT=COMMA12.;
CLASS sec_sr_no SECTOR_NAME subsec_sr_no SUB_SECTOR_NAME;
VAR Ext_tot_Outlay;
TABLE sec_sr_no='Sr. No.' * SECTOR_NAME='Sector' * subsec_sr_no='Sr. No.' * SUB_SECTOR_NAME='Sub-Sector',
Ext_tot_Outlay='Annual' * SUM='Exp';
RUN;
i want
Is there an option in PROC TABULATE to adjust the vertical placement or spacing of row headers? If not, what’s the best alternative (e.g., PROC REPORT) to achieve this customization?
Thank you!
Nope. But you can use PROC REPORT to achieve this report.
PROC REPORT DATA=sashelp.heart nowd;
column status sex bp_status smoking_status ('Annual' weight);
define status/group 'Sr. No.' ;
define sex/group 'Sector';
define bp_status/group 'Sr. No.';
define smoking_status/group 'Sub-Sector';
define weight/analysis sum 'Exp' f=COMMA12.;
run;
Thanks For your Respose, But i want the headers (Sr. No., Sector, Sr. No., Sub-Sector) to be moved up in the output
That would be a little complicated.
proc summary data=sashelp.heart nway;
class status sex bp_status smoking_status;
var weight;
output out=have sum=;
run;
data have2;
set have(drop=_:);
by status sex bp_status smoking_status;
if not first.status then call missing(status);
if not first.sex then call missing(sex);
if not first.bp_status then call missing(bp_status);
if not first.smoking_status then call missing(smoking_status);
run;
ods rtf file="c:\temp\odsr_column_span.rtf" style=minimal;
title "Complex Column Spanning";
data _null_;
set have2 end=last;
if _N_ = 1 then do;
dcl odsout obj();
obj.table_start();
obj.head_start();
** Header row 1;
obj.row_start(type:"Header");
obj.format_cell(text: "status", row_span:2,style_attr:"color=black vjust=m ");
obj.format_cell(text: "sex", row_span:2, style_attr:"color=black vjust=m");
obj.format_cell(text: "bp_status", row_span:2, style_attr:"color=black vjust=m");
obj.format_cell(text: "smoking_status", row_span:2, style_attr:"color=black vjust=m");
obj.format_cell(text: "Annual", row_span:1, style_attr:"color=black ");
obj.row_end();
** Header row 2;
obj.row_start(type:"Header");
obj.format_cell(text: "Exp", row_span:1, style_attr:"color=black");
obj.row_end();
obj.head_end();
end;
** row for every obs;
obj.row_start();
obj.format_cell(data: status, row_span:1);
obj.format_cell(data: sex, row_span:1);
obj.format_cell(data: bp_status, row_span:1);
obj.format_cell(data: smoking_status, row_span:1);
obj.format_cell(data: weight, row_span:1);
obj.row_end();
if last then do;
obj.table_end();
end;
run;
ods rtf close;
title; footnote;
Hi:
Why do you need a cell division between the word "Annual" and "Exp"?
Using the SASHELP.HEART data you could do this with PROC REPORT if you put Annual and Exp in the same header cell:
Cynthia
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.