- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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-
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content