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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.