The SAS Output Delivery System and reporting techniques

Does anyone knows whether we can creat several PDF files using SAS

Reply
Learner
Posts: 1

Does anyone knows whether we can creat several PDF files using SAS

HI all,

I was trying to make a macro do loop to create several PDF files, however, failed.

Does anyone know how to create several PDF files using a do loop?

thanks,

alice

Grand Advisor
Posts: 9,713

Re: Does anyone knows whether we can creat several PDF files using SAS

If you posted the loop code we might be able to provide a quick fix but something like this is a rough structure:

%macro pdfloop();

     %do I = 1 %to 4;

          ods pdf file="c:\path\file&I..pdf" ; /* put the pdf options on that line*/

          proc print data=sashelp.class;run;

          ods pdf close;

     %end;

%mend;

%pdfloop();

If you tried to loop through a list of character values as in %do name= Bill,John,Fred; then you will get a failure as the Macro %do loop doesn't allow text arguments as the data step do loop does.

SAS Super FREQ
Posts: 8,643

Re: Does anyone knows whether we can creat several PDF files using SAS

This works for me. If it doesn't work for you, then I suggest working with Tech Support by sending them your code and a sample of your data.

Cynthia

%macro dopdf;

  %do i = 1 %to 3;
     %if &i = 1 %then %let dsn=sashelp.class;
     %else %if &i = 2 %then %let dsn=sashelp.cars;
     %else %let dsn=sashelp.prdsale;

  

     ods pdf file="c:\temp\out&i..pdf";
      proc print data=&dsn (obs=5);
        title "Loop is: &i and Data is: &dsn";
      run;
     ods pdf close;
  %end;

%mend dopdf;

 

%dopdf

Post a Question
Discussion Stats
  • 2 replies
  • 908 views
  • 0 likes
  • 3 in conversation