Ods pdf page break based on value of variable in macro loop

Accepted Solution Solved
Reply
Contributor
Posts: 40
Accepted Solution

Ods pdf page break based on value of variable in macro loop

Hello,

I would greatly appreciate someone helping me with the following: 

I have a macro that outputs individual pdf documents.  At the end of each pdf document, there are a variable number of tables - each printed in pairs. I have created a variable "i" that determines how many pairs of tables are created.  The creation of the "i" pairs of tables at the end of each document works as expected, but the pages are breaking in between the pairs of tables, which is not what I want to occur.  I want to create a page break after the first pair, third pair, fifth pair, etc.  

Here's a basic visual of what I need:

When i=1

Table 1a

Table 1b

Page break

 

When i=2

Table 2a

Table 2b

 

When i=3

Table 3a

Table 3b

Page break

 

etc...

 

I have added the following code to my program to break right before the second, fourth and sixth tables, etc., but it is giving me an error.  Any suggestions??

 

if mod(&i,2)=0 %then ods pdf startpage=now;

 

<Then code for printing the two tables goes here>

 

Thanks,

KelseyB


Accepted Solutions
Solution
‎10-20-2015 07:05 PM
Super User
Posts: 11,343

Re: Ods pdf page break based on value of variable in macro loop

[ Edited ]

It is very helpful when you get errors to post the code and the full error message.

 

If this code is part of  a macro:

if mod(&i,2)=0 %then ods pdf startpage=now;

which seems likely then the error would be use of data step code in the wrong place in a macro.

 

%if %sysfunc(mod(&i,2))=0 %then %do; ods pdf startpage=now; %end;

Might get closer.

View solution in original post


All Replies
Solution
‎10-20-2015 07:05 PM
Super User
Posts: 11,343

Re: Ods pdf page break based on value of variable in macro loop

[ Edited ]

It is very helpful when you get errors to post the code and the full error message.

 

If this code is part of  a macro:

if mod(&i,2)=0 %then ods pdf startpage=now;

which seems likely then the error would be use of data step code in the wrong place in a macro.

 

%if %sysfunc(mod(&i,2))=0 %then %do; ods pdf startpage=now; %end;

Might get closer.

Contributor
Posts: 40

Re: Ods pdf page break based on value of variable in macro loop

Thank you Ballardw.  That worked perfectly!  Sorry I normally post my error, but I forgot this time.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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