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

I run the following code

 

data one;
	do i=1 to 20;
		rannum=rand('Uniform');
		output;
	end;
run;

/* one */

footnote 
	justify=left "left text"
	justify=center "center text"
	justify=right "right text"; 

options nodate nonumber;

ods pdf file="file1.pdf" notoc;                                                                                                          

options orientation=portrait; 

title "&sysver: Orientation=Portrait";   
 proc print data=one;
run; 
                                                                                                                                        
options orientation=landscape;                                                                                                          
                                                                                                                                        
title "&sysver: Orientation=Landscape";                                                                                                 
proc print data=one;
run; 
                                                                                                                                        
options orientation=portrait;  
 
title "&sysver: Orientation=Portrait";                                                                                                  
proc print data=one;
run; 
                                                                                                                                        
ods pdf close;   

and I get something that looks right

 

run1.JPG

 

Then I run the following 

 

ods escapechar="^";

footnote 
	justify=left "left text"
	justify=center 'Page ^{thispage} of ^{lastpage}'
	justify=right "right text"; 
 
ods pdf file="file2.pdf" notoc; 
 
options orientation=portrait;   
 
title "&sysver: Orientation=Portrait";                                                                                                  
proc print data=one;
run; 
                                                                                                                                        
options orientation=landscape;                                                                                                          
                                                                                                                                        
title "&sysver: Orientation=Landscape";                                                                                                 
proc print data=one;
run; 
                                                                                                                                        
options orientation=portrait;  
 
title "&sysver: Orientation=Portrait";                                                                                                  
proc print data=one;
run; 
                                                                                                                                        
ods pdf close;    

and two things occur.

The pagination is wrong.  It is somehow counting 5 pages instead of 3, and the second page appears to be off to the right of the page somewhere as if it is trying to reorient, but just cut off the document.run2.JPG

Is there a way to change the orientation and keep the page x of y in place, or do I have to choose one or the other?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:

  What you report I do not observe using 9.4M7. I tweaked your code just a bit. I put the first option before the first ODS PDF invocation in both steps. I also added specific margin options. Then, after every orientation change, I put an ODS PDF: statement. This was recommended to me as a way to get ODS PDF to go out and refresh options. I get the desired results, as shown below:

File1.PDF:

Cynthia_sas_0-1676588343775.png

 

File2.PDF:

Cynthia_sas_1-1676588483880.png

 

 

I had to meld 2 screen shots together to get all 3 pages in one image.

 

  You'll notice I used SASHELP.CLASS, it has 19 rows, there was really no need to make data with an extra step. I also changed the title to use &sysvlong4 instead of &sysver because I wonder whether your issue might be related to a specific maintenance release. I was running on a Windows 10 system. But I would expect the same output to be produced no matter where you were running.

 

  Here's my code:

** test 1;
  
footnote 
	justify=left "left text"
	justify=center "center text"
	justify=right "right text"; 

**specify starting options and starting orientation before ODS PDF starts;
options nodate nonumber orientation=portrait topmargin=.5in bottommargin=.5in leftmargin=.5in rightmargin=.5in 
        pageno=1;

ods pdf file="c:\temp\file1.pdf" notoc;      

title "&sysvlong4: Orientation=Portrait";   
 proc print data=sashelp.class;
run; 
      
options orientation=landscape;   
ods pdf; 
      
title "&sysvlong4: Orientation=Landscape";       
proc print data=sashelp.class;
run; 
      
options orientation=portrait;  
ods pdf;
 
title "&sysvlong4: Orientation=Portrait";        
proc print data=sashelp.class;
run; 
      
ods pdf close;   

**test2;

ods escapechar="^";

footnote 
	justify=left "left text"
	justify=center 'Page ^{thispage} of ^{lastpage}'
	justify=right "right text"; 
 
** specify starting options and orientation before ODS PDF starts;
options orientation=portrait topmargin=.5in bottommargin=.5in leftmargin=.5in rightmargin=.5in nodate nonumber pageno=1;   
 
ods pdf file="c:\temp\file2.pdf" notoc; 

title "&sysvlong4: Orientation=Portrait";        
proc print data=sashelp.class;
run; 
      
options orientation=landscape;    
ods pdf; 
      
title "&sysvlong4: Orientation=Landscape";       
proc print data=sashelp.class;
run; 
      
options orientation=portrait;  
ods pdf;
 
title "&sysvlong4: Orientation=Portrait";        
proc print data=sashelp.class;
run; 
      
ods pdf close;    

  If you are running SAS 9.4 M7 and you run my code and do not get the same results, that that is something that you should report to Tech Support. To open a track with Tech Support, fill out the form at this link: http://support.sas.com/ctx/supportform/createForm and be sure to include your site license number. You can point them to this track so they can get the code out of the track.

Cynthia

View solution in original post

2 REPLIES 2
Cynthia_sas
Diamond | Level 26

Hi:

  What you report I do not observe using 9.4M7. I tweaked your code just a bit. I put the first option before the first ODS PDF invocation in both steps. I also added specific margin options. Then, after every orientation change, I put an ODS PDF: statement. This was recommended to me as a way to get ODS PDF to go out and refresh options. I get the desired results, as shown below:

File1.PDF:

Cynthia_sas_0-1676588343775.png

 

File2.PDF:

Cynthia_sas_1-1676588483880.png

 

 

I had to meld 2 screen shots together to get all 3 pages in one image.

 

  You'll notice I used SASHELP.CLASS, it has 19 rows, there was really no need to make data with an extra step. I also changed the title to use &sysvlong4 instead of &sysver because I wonder whether your issue might be related to a specific maintenance release. I was running on a Windows 10 system. But I would expect the same output to be produced no matter where you were running.

 

  Here's my code:

** test 1;
  
footnote 
	justify=left "left text"
	justify=center "center text"
	justify=right "right text"; 

**specify starting options and starting orientation before ODS PDF starts;
options nodate nonumber orientation=portrait topmargin=.5in bottommargin=.5in leftmargin=.5in rightmargin=.5in 
        pageno=1;

ods pdf file="c:\temp\file1.pdf" notoc;      

title "&sysvlong4: Orientation=Portrait";   
 proc print data=sashelp.class;
run; 
      
options orientation=landscape;   
ods pdf; 
      
title "&sysvlong4: Orientation=Landscape";       
proc print data=sashelp.class;
run; 
      
options orientation=portrait;  
ods pdf;
 
title "&sysvlong4: Orientation=Portrait";        
proc print data=sashelp.class;
run; 
      
ods pdf close;   

**test2;

ods escapechar="^";

footnote 
	justify=left "left text"
	justify=center 'Page ^{thispage} of ^{lastpage}'
	justify=right "right text"; 
 
** specify starting options and orientation before ODS PDF starts;
options orientation=portrait topmargin=.5in bottommargin=.5in leftmargin=.5in rightmargin=.5in nodate nonumber pageno=1;   
 
ods pdf file="c:\temp\file2.pdf" notoc; 

title "&sysvlong4: Orientation=Portrait";        
proc print data=sashelp.class;
run; 
      
options orientation=landscape;    
ods pdf; 
      
title "&sysvlong4: Orientation=Landscape";       
proc print data=sashelp.class;
run; 
      
options orientation=portrait;  
ods pdf;
 
title "&sysvlong4: Orientation=Portrait";        
proc print data=sashelp.class;
run; 
      
ods pdf close;    

  If you are running SAS 9.4 M7 and you run my code and do not get the same results, that that is something that you should report to Tech Support. To open a track with Tech Support, fill out the form at this link: http://support.sas.com/ctx/supportform/createForm and be sure to include your site license number. You can point them to this track so they can get the code out of the track.

Cynthia

jtcowder
Fluorite | Level 6

Thank you for your response.

Using your code, I get the same issue I had to begin with.

As you point out, it very well may be related to the maintenance release as I am running 

9.04.01M6P11072018.

 

I included a screen shot of page two, which is displaying wrong.  One and Three are as expected.sasissue02.JPG

 

Thank you again.

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