Hi all !
I think I have a solution that does not need any macro loops. Just import your files with FILEVAR, retain a variable that says which file you've been reading from, then use that variable in a BY statement in the Print procedure and the NEWFILE=BYGROUP option in the ODS PDF statement.
For example :
DATA work.ImportedData ;
INPUT file :$40. ;
INFILE MISSOVER DLM = "09"x DSD FILEVAR = file END = finished ;
changePDF = file ;
DO WHILE (NOT FINISHED) ;
INPUT country :$30. year month :$10. product :$30. actual :dollar12.2 predict :dollar12.2 ;
ODS PDF FILE = "c:\temp\sales2.pdf" NEWFILE = BYGROUP ;
OPTION NOBYLINE ;
PROC PRINT DATA = work.importedData LABEL NOOBS ;
VAR country year month product actual predict ;
BY changePDF ;
OPTION BYLINE ;
ODS PDF CLOSE ;
I think that NEWFILE= did not work for PDF in SAS 8.2 -- but, the general approach that Olivier outlined should still work for you. If you have a variable that identifies which file your information came from, then you could treat that variable as the "BY" variable.
The macro program would be something like what is shown below. It would have to be adjusted for your variables and data values.
*** the code;
ods pdf file="&byval..pdf";
proc print data=big_dsn;
where dsnvar = "&byval";
ods pdf close;