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
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.
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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.