I have a problem when using the sas report writing interface to create a pdf file. My table has a column need a long header, so I split it into two lines. however, there will be an extra space generated in the first row. Please look at the sample pdf and see the difference between the first row of two table header. the only difference of the code to create the two tables is the second table use a split header "Student*Name" in first column. how can I remove the extra space in second table? Thanks in advance!
below is my code of the example
options nodate nonumber;
ods listing close;
ods pdf file="test.pdf" startpage=never;
title "Table Using Column and Row Spanning";
title2 "Two Tables, One for Females and One for Males";
proc format;
value $gender
F = "Females"
M = "Males"
;
run;
proc sort data=sashelp.class out=class;
by sex;
run;
data _null_;
set class;
where sex = 'F';
by sex;
if _N_ = 1 then do;
dcl odsout obj();
end;
if first.sex then do;
obj.table_start();
obj.head_start();
obj.row_start();
obj.format_cell(data: "Name", row_span: 2, vjust: "M");
obj.format_cell(data: sex, column_span: 4, format: "$gender.");
obj.row_end();
obj.row_start();
obj.format_cell(data: "Age");
obj.format_cell(data: "Height");
obj.format_cell(data: "Weight");
obj.format_cell(data: "BMI");
obj.row_end();
obj.head_end();
end;
bmi = ( weight / ( height * height ) ) * 703;
obj.row_start();
obj.format_cell(data: name);
obj.format_cell(data: age);
obj.format_cell(data: height);
obj.format_cell(data: weight);
obj.format_cell(data: bmi, format: "8.2");
obj.row_end();
if last.sex then do;
obj.table_end();
end;
run;
data _null_;
set class;
where sex='F';
by sex;
if _N_ = 1 then do;
dcl odsout obj();
end;
if first.sex then do;
obj.table_start();
obj.head_start();
obj.row_start();
obj.format_cell(data: "Student*Name", split: '*', row_span: 2, vjust: "M");
obj.format_cell(data: sex, column_span: 4, format: "$gender.");
obj.row_end();
obj.row_start();
obj.format_cell(data: "Age");
obj.format_cell(data: "Height");
obj.format_cell(data: "Weight");
obj.format_cell(data: "BMI");
obj.row_end();
obj.head_end();
end;
bmi = ( weight / ( height * height ) ) * 703;
obj.row_start();
obj.format_cell(data: name);
obj.format_cell(data: age);
obj.format_cell(data: height);
obj.format_cell(data: weight);
obj.format_cell(data: bmi, format: "8.2");
obj.row_end();
if last.sex then do;
obj.table_end();
end;
run;
ods pdf close;
ods listing;
One for tech support I think.
In the mean time this seems to work somewhat:
obj.format_cell(data: "Student Name", row_span: 2, vjust: "M",overrides: "height=6mm");
obj.format_cell(data: sex, column_span: 4, format: "$gender.",overrides: "height=3mm");
I have no answer, but could this be due to the reader (Adobe's) being buggy?
If you replace
obj.format_cell(data: "Student*Name", split: '*', row_span: 2, vjust: "M");
with
obj.format_cell(data: "Student"||'0a'x||"Name", row_span: 2, vjust: "M");
or
obj.format_cell(data: "Student Name", row_span: 2, vjust: "M");
the result is the same.
So there is probably nothing in the PDF itself indicating the larger height.
Have you tried with other readers?
One for tech support I think.
In the mean time this seems to work somewhat:
obj.format_cell(data: "Student Name", row_span: 2, vjust: "M",overrides: "height=6mm");
obj.format_cell(data: sex, column_span: 4, format: "$gender.",overrides: "height=3mm");
Thank you!
This method works. through I need manually adjust the row height each time.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.