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

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

Accepted Solutions
jerry898969
Pyrite | Level 9

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

2 REPLIES 2
ballardw
Super User

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.

 

 

jerry898969
Pyrite | Level 9

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 ;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

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
  • 2 replies
  • 1517 views
  • 0 likes
  • 2 in conversation