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 ;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 967 views
  • 0 likes
  • 2 in conversation