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

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!

 

test.jpg

 

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; 
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

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");

 

Capture.PNG

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

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?

 

 

 

 

 

cxterm
Fluorite | Level 6
Thanks for reply. I have tried your suggestion, but The same result. I also used several other viewer, still The same extra space there.
ChrisNZ
Tourmaline | Level 20

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");

 

Capture.PNG

cxterm
Fluorite | Level 6

Thank you! 

This method works. through I need manually adjust the row height each time. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1637 views
  • 0 likes
  • 2 in conversation