The SAS Output Delivery System and reporting techniques

PDF ODS only lines up data on the first row

Accepted Solution Solved
Reply
Super Contributor
Posts: 398
Accepted Solution

PDF ODS only lines up data on the first row

Hello,

 

I'm trying to generate a ods pdf file and it is generating and the first row displays correctly.  The issue I'm having is the follow up rows are off by 1 space from lining up.   I tried changing the indent and it didn't fix it.

 


*Create pdf ;
ods listing ; 
title ; 
footnote ;
options orientation=portrait 
		topmargin=.75in bottommargin=.75in rightmargin=.75in leftmargin=.75in 
		pageno=1 nodate nonumber nocenter 
	;
ods listing close ;
ods escapechar='^' ; 
ods pdf file = "c:\temp.pdf" notoc ;
footnote j=c height=8pt  font='Courier New' 'Page ^{thispage} of ^{lastpage}' ;

ods pdf startpage=now ;
ods pdf text="^S={font_size=16pt font_face='Times New Roman' fontweight=bold just=center}&title.^S={}" ;
ods pdf text="^2n" ;

data _null_ ;	    
	set temp end=lastObs ;
	by id ;
	declare odsout obj() ;		
	obj.table_start(overrides: 'frame=void rules=none cellpadding=0in cellspacing=.06in ' ) ;
	obj.body_start() ;
	
	if id=1 then do ;
		obj.row_start() ;
			obj.format_cell(text: "&heading.", overrides: "height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
		obj.row_end() ;
		obj.row_start() ;
			obj.format_cell(text: 'Varnum', overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
			obj.format_cell(text: 'Name',  overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
			obj.format_cell(text: 'Label', overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
		obj.row_end() ;		
	end ;
				
	obj.row_start() ;
		obj.format_cell(text: varid, overrides: "indent=40 height=.06in cellwidth=1in backgroundcolor=white just=left font_face='Courier New' font_size=9pt ") ;								
		obj.format_cell(text: varname, overrides: "indent=40 height=.06in cellwidth=1in backgroundcolor=white just=left font_face='Courier New' font_size=9pt ") ;								
		obj.format_cell(text: varlabel,  overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' font_size=9pt ") ;								
	obj.row_end() ;

	if last.id then do ;
		obj.body_end() ;
		obj.table_end() ;
	end ;
run ;

ods pdf close ;
ods listing ;

Accepted Solutions
Solution
‎11-02-2016 09:00 AM
Super Contributor
Posts: 398

Re: PDF ODS only lines up data on the first row

Hi ballardw,

 

I apologize for not adding example data.  I should have created a temp version of my table that the code could run against.

 

I was able to correct this issue this morning.   Since there are 3 cells in the data portion and only 1 cell in the heading row it was causes the column headings and data not to line up.  Once I added 2 blank cells it corrected the issue I was having.

 

if id=1 then do ;
		obj.row_start() ;
			obj.format_cell(text: "&heading.", overrides: "height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
obj.format_cell(text: '',  overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
obj.format_cell(text: '',  overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
		obj.row_end() ;
		obj.row_start() ;
			obj.format_cell(text: 'Varnum', overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
			obj.format_cell(text: 'Name',  overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
			obj.format_cell(text: 'Label', overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
		obj.row_end() ;		
	end ;

View solution in original post


All Replies
Grand Advisor
Posts: 9,748

Re: PDF ODS only lines up data on the first row

You should provide some example data for folks to test your code with and test suggestions beforehand. https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... has instructions on how to turn your dataset, or a portion, into data step code that can be pasted into the forum for us to recreate the data and attempt to duplicate the problem you have.

 

It also often helps to provide an example of the output so we can actually see the result. "Doesn't line up" does not mean much without see what actually doesn't align.

 

 

Solution
‎11-02-2016 09:00 AM
Super Contributor
Posts: 398

Re: PDF ODS only lines up data on the first row

Hi ballardw,

 

I apologize for not adding example data.  I should have created a temp version of my table that the code could run against.

 

I was able to correct this issue this morning.   Since there are 3 cells in the data portion and only 1 cell in the heading row it was causes the column headings and data not to line up.  Once I added 2 blank cells it corrected the issue I was having.

 

if id=1 then do ;
		obj.row_start() ;
			obj.format_cell(text: "&heading.", overrides: "height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
obj.format_cell(text: '',  overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
obj.format_cell(text: '',  overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
		obj.row_end() ;
		obj.row_start() ;
			obj.format_cell(text: 'Varnum', overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
			obj.format_cell(text: 'Name',  overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
			obj.format_cell(text: 'Label', overrides: "indent=40 height=.06in backgroundcolor=white just=left font_face='Courier New' fontweight=bold") ;
		obj.row_end() ;		
	end ;
Post a Question
Discussion Stats
  • 2 replies
  • 221 views
  • 0 likes
  • 2 in conversation