SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
sandhyababu
Calcite | Level 5

Hi All,

 

I am working on SAS in the mainframe environment. I have 3 input files with different data that I need to process. I am processing each input file in a separate step within the JCL and writing the SAS observations to the one output file using PROC PRINTTO in 3 steps respectively. I have created one output file with 3 different reports. 

 

All the reports are appearing one after the other in the file. I am looking for options to add a page break after each report so the next report starts on a new page instead of appearing in the same page as the previous report.

 

Could you please advise on what option I could use to do this?

6 REPLIES 6
Astounding
PROC Star

You're actually creating the problem by using 3 steps instead of 1.  SAS can process many DATA and PROC steps within the same EXEC step, and will take care of the page numbering for you.

sandhyababu
Calcite | Level 5

Thank you for the suggestion! 

 

I combined all of the steps into one step to execute SAS within the JCL. I now tried to add 3 input files to same SAS step, processed each input file in a separate data step. I added one PROC PRINTTO and 3 PROC PRINTS within to write the data to the output file. I am still not getting the 3 reports on separate pages. Below sample is how I am doing. Am I doing something wrong?

 

//Step EXEC SAS

-input files-

Data file1;

-Process data-

Data file 2;

-Process data-

Data file3;

-Process data-

 

PROC PRINTTO PRINT='file';

PROC PRINT data=file1;

-titles, vars-

PROC PRINT data=file2;

-titles,vars-

PROC PRINT data=file3;

-titles,vars-

PROC PRINTTO;

RUN;

Astounding
PROC Star

Why use PROC PRINTTO at all?  Why not let SAS use the file it would normally use to hold procedure output?

 

I would guess that the JCL you have used to define the output file does not hold the proper DCB characteristics that would include page breaks.  You could check that by inspecting the JCL log.  But it's much simpler just to remove both of the PROC PRINTTOs.  

 

One thing to consider if you really need results in a file as well as a printed report with page breaks ... you could print the data twice.  In the program you now have, just repeat all 3 PROC PRINTs, after the final PROC PRINTTO.

sandhyababu
Calcite | Level 5

Thank you for the suggestion!

 

I tried the following by removing the PROC PRINTTO and just printing all 3 files one after the other in 3 PROC PRINTS. The SASLIST contains all 3 reports one after the other without a page break. Could you please let me know what is wrong with the below. Thanks in advance!

 

//Step EXEC SAS

-input files-

Data file1;

-Process data-

Data file 2;

-Process data-

Data file3;

-Process data-

 

PROC PRINT data=file1;

-titles, vars-

PROC PRINT data=file2;

-titles,vars-

PROC PRINT data=file3;

-titles,vars-

SASJedi
Ammonite | Level 13

You can try appending a form feed character (FF) using a DATA _NULL_ step after creating the output. I don't have ready access to a mainframe right now, but this SHOULD work.

Try something like this:

filename myprint file="myuid.printer.flatfile" DISP=mod;
proc printto print=myprint new;
run;

title "Report 1";
proc print data=sashelp.class;
   where sex='F';
run;
proc printto;run;
/* Add the form feed: */
data _null_;
  file myprint mod;
  put _page_;
run;

Rather than use PROC PRINTTO, you might consider using ODS to write the output instead:

ods listing file="myuid.printer.flatfile" DISP=mod;
title "Report 1";
proc print data=sashelp.class;
   where sex='F';
run;
ods listing close;

I will say that Windows printers do not honor the Form Feed character when printing text files - so not sure this will fix it for you. Do you have other processes running on the mainframe that successfully append multiple reports to a single file and subsequently print each report on separate pages? Because if not, it may just be that your more modern printer is ignoring the embedded FF character.

So, the suggestion from @Astounding to make all of the reports in a single SAS EXEC step might be the better answer.

Regards,
Mark

 

Check out my Jedi SAS Tricks for SAS Users
sandhyababu
Calcite | Level 5
Thank you for the suggestions. I will try the ODS option and I am also trying suggestion from @Astounding.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 6 replies
  • 2590 views
  • 2 likes
  • 3 in conversation