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

Hi everyone,

 

I'm producing a report in pdf concatenating PROC REPORT procedures and depending on the resulting table width I'm turning the page to landscape or back to portrait as needed. Each table starts in a new page.

 

I'm starting with portrait orientation and everything looks fine: the produced table fits the page width (I'm using style(report)={width=100%} in the PROC REPORT) and the defined footnote appears where it should as well as a header preimage defined in the template I'm using. However, when I change to landscape the table is truncated on the right and the footnote dissapears. Everything points out to an issue with the definition of the landscape page parameters but I can't figure out where is the problem.

 

Moreover, once I have turned to landscape the first time, all the following portrait-oriented pages get messy too while if I comment the landscape parts every portrait page is outputed nicely.

 

I'm attaching here an example of my code but please tell me if you think that any other part could be interesting to detect the issue:

 

		* Open ODS to create Patient Profile report (portrait);
		options orientation=portrait nodate nonumber papersize=A4;
		goptions reset=goptions device=sasemf target=sasemf xmax=7.5in ymax=10in;
		ods pdf dpi=700 style=template_portrait file="&outputpath/Patient Profile report - &patID (&sysdate).pdf" pdftoc=1;

		* Remove residual titles and define footnote;
		title;
		footnote;
		title ' '; * this is needed for the logo image to appear;
		ods escapechar='~';
		footnote j=l h=1.75 "&studyname" j=r h=1.75 "Page ~{thispage}";

		*----------------------------------------------------------------------------;
		* DEMOGRAPHICS													 			 ;
		*----------------------------------------------------------------------------;

		proc report data=_auxdemo nowd headline style(header)={background=very light grey fontsize=8pt} missing style(column)={fontsize=8pt} style(report)={width=100%};
			column ("Demographics of patient &patID." siteid gender age cmdecod);
			define siteid / display 'Site' flow;
			define gender / display 'Gender' flow;
			define age / display 'Age (years)' flow;
			define cmdecod / display 'Previous immunotherapy' flow;
		run;

		*----------------------------------------------------------------------------;
		* VITAL SIGNS PER VISIT 								 			 		 ;
		*----------------------------------------------------------------------------;

		* Turn to landscape;
		options orientation=landscape nodate nonumber papersize=A4;
		goptions reset=goptions device=sasemf target=sasemf xmax=10in ymax=7.5in;
		ods pdf style=template_landscape;

		proc report data=_auxvs nowd headline style(header)={background=very light grey fontsize=8pt} missing style(column)={fontsize=8pt} style(report)={width=100%};
			column ("Vital signs per visit of patient &patID." visit vsdat sysbp vsgyn1 vsgchr1);
			define visit / display 'Visit' flow;
			define vsdat / display 'Vitals Date' flow;
			define sysbp / display 'Value (mmHg)' flow;
			define vsgyn1 / display 'Clin. sig.?' flow;
			define vsgchr1 / display 'Specify' flow;
		run;

		* Go back to portrait orientation;
		options orientation=portrait nodate nonumber papersize=A4;
		goptions reset=goptions device=sasemf target=sasemf xmax=7.5in ymax=10in;
		ods pdf style=template_portrait;

		*----------------------------------------------------------------------------;
		* END OF STUDY REASONS 					 							 		 ;
		*----------------------------------------------------------------------------;

		proc report data=_auxeos nowd headline style(header)={background=very light grey fontsize=8pt} missing style(column)={fontsize=8pt} style(report)={width=100%};
			column ("End of study reason of patient &patID." dsdat3 dsstdat dsglst1 dsglst2);
			define dsdat3 / display 'Date of last contact with subject' flow;
			define dsstdat / display 'Date of last dose in the study' flow;
			define dsglst1 / display 'EOS status' flow;
			define dsglst2 / display 'Reason for screening failure or discontinuation' flow;
		run;

		ods pdf close;

Here you have the two style templates that I'm using. They are the same except for the preimage which is different depending on the orientation.

 

/* Portrait template														*/

proc template;
	define style template_portrait;
		parent = styles.default;
		style Body from Document                                                
			"Controls the Body file." /                                          
			marginbottom = 2cm                                                
			margintop = 2cm                                                   
			marginright = 2cm                                                 
			marginleft = 2cm;
		style fonts /                                                           
			'TitleFont2' = ("Arial",10pt,Italic)                             
			'TitleFont' = ("Arial",10pt,Italic)                              
			'StrongFont' = ("Arial",9pt,Bold)                                    
			'EmphasisFont' = ("Arial",9pt,Italic)                                
			'FixedEmphasisFont' = ("Arial, Courier",8pt,Italic)                  
			'FixedStrongFont' = ("Courier New, Courier",8pt,Bold)                
			'FixedHeadingFont' = ("Courier New, Courier",8pt,Bold)               
			'BatchFixedFont' = ("SAS Monospace, Arial",8pt)         
			'FixedFont' = ("Arial",8pt)                           
			'headingEmphasisFont' = ("Arial",8pt,Bold Italic)                    
			'headingFont' = ("Arial",8pt,Bold)                                   
			'docFont' = ("Arial",8pt);
		style titleAndNoteContainer from titleAndNoteContainer /                
			width = _undef_;
		style cell from container /                                             
			linkcolor = colors('link2');
		style table from table /                                                
			padding = 3pt;
		style Table from Output /
			rules = rows
			frame = hsides
			bordercolor = CX27323F;
		style batch from batch /                                                
			rules = none                                                         
			frame = void                                                         
			padding = 0pt                                                        
			borderspacing = 0pt;
		style Byline from Byline                                                
			"Controls byline text." /                                            
			frame = void;
		style color_list /                                                     
			'contentfg' = cx000000                                               
			'contentbg' = cxFFFFFF                                               
			'fgB2' = CX27323F                                                     
			'fgB1' = CX27323F                                                    
			'fgA4' = CX27323F                                                    
			'bgA4' = cxFFFFFF                                                    
			'bgA3' = cxFFFFFF                                                    
			'fgA2' = CX27323F                                                    
			'bgA2' = cxFFFFFF                                                    
			'fgA1' = CX27323F                                                     
			'bgA1' = cxFFFFFF                                                    
			'fgA' = CX27323F                                                    
			'bgA' = cxFFFFFF;
		style GraphBox from GraphBox /                                          
			displayopts = "fill caps median mean outliers";
		style GraphHistogram from GraphHistogram /                              
			displayopts = "fill outline";
		style GraphEllipse from GraphEllipse /                                  
			displayopts = "outline";
		style GraphBand from GraphBand /                                        
			displayopts = "fill";
		class cell /
			textalign=center;
	  	class header /        
			textalign=center;
		style  systemtitle /
			textalign=l 
			verticalalign=t
			preimage="C:\mypath\Logo_portrait.png" foreground = #ffffff;
	end;
run;

/* Landscape template 													*/

proc template;
	define style template_landscape;
		parent = styles.default;
		style Body from Document                                                
			"Controls the Body file." /                                          
			marginbottom = 2cm                                                
			margintop = 2cm                                                   
			marginright = 2cm                                          
			marginleft = 2cm;
		style fonts /                                                           
			'TitleFont2' = ("Arial",10pt,Italic)                             
			'TitleFont' = ("Arial",10pt,Italic)                              
			'StrongFont' = ("Arial",9pt,Bold)                                    
			'EmphasisFont' = ("Arial",9pt,Italic)                                
			'FixedEmphasisFont' = ("Arial, Courier",8pt,Italic)                  
			'FixedStrongFont' = ("Courier New, Courier",8pt,Bold)                
			'FixedHeadingFont' = ("Courier New, Courier",8pt,Bold)               
			'BatchFixedFont' = ("SAS Monospace, Arial",8pt)         
			'FixedFont' = ("Arial",8pt)                           
			'headingEmphasisFont' = ("Arial",8pt,Bold Italic)                    
			'headingFont' = ("Arial",8pt,Bold)                                   
			'docFont' = ("Arial",8pt);
		style titleAndNoteContainer from titleAndNoteContainer /                
			width = _undef_;
		style cell from container /                                             
			linkcolor = colors('link2');
		style table from table /                                                
			padding = 3pt;
		style Table from Output /
			rules = rows
			frame = hsides
			bordercolor = CX27323F;
		style batch from batch /                                                
			rules = none                                                         
			frame = void                                                         
			padding = 0pt                                                        
			borderspacing = 0pt;
		style Byline from Byline                                                
			"Controls byline text." /                                            
			frame = void;
		style color_list /                                                      
			'contentfg' = cx000000                                               
			'contentbg' = cxFFFFFF                                               
			'fgB2' = CX27323F                                                     
			'fgB1' = CX27323F                                                    
			'fgA4' = CX27323F                                                    
			'bgA4' = cxFFFFFF                                                    
			'bgA3' = cxFFFFFF                                                    
			'fgA2' = CX27323F                                                    
			'bgA2' = cxFFFFFF                                                    
			'fgA1' = CX27323F                                                     
			'bgA1' = cxFFFFFF                                                    
			'fgA' = CX27323F                                                    
			'bgA' = cxFFFFFF;         
		style GraphBox from GraphBox /                                          
			displayopts = "fill caps median mean outliers";
		style GraphHistogram from GraphHistogram /                              
			displayopts = "fill outline";
		style GraphEllipse from GraphEllipse /                                  
			displayopts = "outline";
		style GraphBand from GraphBand /                                        
			displayopts = "fill";
		class cell /
			textalign=center;
	  	class header /        
			textalign=center;
		style  systemtitle /
			textalign=l 
			verticalalign=t
			preimage="C:\mypath\Logo_landscape.png"
			foreground = #ffffff;
	end;
run;

 

Here you have an example of the output where you can clearly see the problem:

 

example.png

 

Any tips or suggestions are very much appreciated!

 

Thanks a lot in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
I really think this is something to address with Tech Support. My guess is that it is something else that is really the issue and someone needs to look at ALL your code and your data to help. It bothers me that you have GOPTIONS in your code, but not any SAS/GRAPH statements, but I doubt that is the issue. I really think the issue is more related to trying to switch templates in the middle of the stream, which I did not think was possible.

Cynthia

View solution in original post

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This won't be very helpful I am afraid, but I have always had issues going directly to PDF.  My preference is to create one output per block.  I create RTF output then combine in Acrobat, but you could produce each one separately to PDF, then combine them all.  I find this gives more control over the whole document, and you can chop and change if needed.

emera86
Quartz | Level 8

Thank you for your quick response @RW9.

 

This could be an option but it will require a postprocessing step that I'm trying to avoid. I believe that there must an option that enables me to create the pdf as a whole...

 

Thanks anyway for your help.

Cynthia_sas
SAS Super FREQ
Hi:
I am not sure that you can use 2 different templates in one PDF document. This would be a question for Tech Support. If you remove the templates from the picture and the preimage and just run the PROC REPORTs and switch orientation in between steps, does the table still get truncated? I'm just curious. My guess is that you'll need to work with Tech Support on this.

Cynthia
emera86
Quartz | Level 8

Hi @Cynthia_sas,

 

I tried your sugesstion and everything works fine without the style definition in the ods statement, so I was wondering if it was an specific part of the template code that was making everything crash and I found it: the margin definition.

 

 

		style Body from Document                                                
			"Controls the Body file." /                                          
			marginbottom = 2cm                                                
			margintop = 2cm                                                   
			marginright = 2cm                                                 
			marginleft = 2cm;

 

If I remove this part (which is the same for both templates portrait and landscape, that's why I didn't think of it at first) from the templates that I posted before the tables are not truncated anymore. Do you see something strange in this definition? Any idea of what is happening or how could I define the margins in a different way?

 

Thanks again for your help!

Cynthia_sas
SAS Super FREQ
Hi:
I really think this is something to address with Tech Support. My guess is that it is something else that is really the issue and someone needs to look at ALL your code and your data to help. It bothers me that you have GOPTIONS in your code, but not any SAS/GRAPH statements, but I doubt that is the issue. I really think the issue is more related to trying to switch templates in the middle of the stream, which I did not think was possible.

Cynthia
emera86
Quartz | Level 8

Thanks for your help @Cynthia_sas, I'll talk to Tech Support.

emera86
Quartz | Level 8

In case it's useful for someone I finally managed to solve it moving the margin size definition from the PROC TEMPLATE to the options statement:

 

options orientation=portrait nodate nonumber leftmargin=2cm rightmargin=2cm topmargin=2cm bottommargin=2cm papersize=A4;

 

I also removed the goptions sentences (I may have inherited them from another code containing graphs) as @Cynthia_sas suggested as they didn't have any purpose on this code.

 

Hope this helps!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 7 replies
  • 2492 views
  • 1 like
  • 3 in conversation