BookmarkSubscribeRSS Feed
cosmid
Lapis Lazuli | Level 10
 
 

When you run macros multiple times, how do you make it so that each successful run will print on a new page instead of concatenating the next result to the previous one without a line break?

 

Example:

macro(a);

macro(b);

 

The result will be something like:

Page 1:

        Successful run a

 blah blah blah blah

        Successful run b

more blah blah blah

 

*bunch of blank lines here*

 Page 2:

 

How to make it so that the result from b will start on page 2 or if it is not possible is there a way to add blank lines in between the results? The example has two macros but needs this for a lot more macros.

 

Thanks!

 

 
 
5 REPLIES 5
ballardw
Super User

Are you generating a document or printing directly to a printer?

If a document then what type? Options used?.

 

Macro or not the approaches are generally the same. But where/how you are "printing" is need to know. And the syntax varies a bit depending on the actual destination.

cosmid
Lapis Lazuli | Level 10
Sorry, when I said print, I meant by printing to the output window. When I run the code in SAS studio, with HTML there's a line break for each result, and with listing as the output window, each macro run returns at a new page. But when I do this in UNIX, each macro result just print right below the previous one, there isn't even a line break. So I was wondering if there's an option that I can add to separate each results either with a line break or make sure the new result starts off on a new page.
ballardw
Super User

@cosmid wrote:
Sorry, when I said print, I meant by printing to the output window. When I run the code in SAS studio, with HTML there's a line break for each result, and with listing as the output window, each macro run returns at a new page. But when I do this in UNIX, each macro result just print right below the previous one, there isn't even a line break. So I was wondering if there's an option that I can add to separate each results either with a line break or make sure the new result starts off on a new page.

HTML doesn't really have a concept for "page" so sending such to HTML is pretty problematic.

If you mean the traditional OUTPUT window enabled with ODS LISTING then again, how the output is generated does come into play.

 

I am afraid a list of macro names without any details of the actual macro code involved isn't very helpful.

 

One caution: if you are setting options in SAS studio and then running on a different system then UNIX may use them differently.

cosmid
Lapis Lazuli | Level 10
Sorry, I didn't provide any code. I was referring to results in general. I'm looking for proc prints used in a macro to be more specific. Here's a sample code, and I wanted each macro to print on a new page.

data sample;
input x;
datalines;
1
2
3
run;

%macro print_it();
proc print data=sample;
run;
$mend;

%print_it(); /*first run*/
%print_it(); /*2nd run, but I wanted this to be on page 2*/
%print_it(); /*3rd run, and this should be on page 3*/

It's a small data, but if the result generated takes more than one page, then the next macro result should be on the next page of the previous macro's result.
cosmid
Lapis Lazuli | Level 10
I am using a temporary solution, something like as follows:

%print_something(a);
%print_line_break();
%print_something(b);
%print_line_break();
%print_something(c);
%print_line_break();

Where the print_line_break() is just a proc print statement I put inside to print out a constant text like ---------- to separate out the result. It works, but not pretty. I was hoping there's a way to separate them to different pages or a more standard way, like with an option, that adds a line break.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1201 views
  • 1 like
  • 2 in conversation