The SAS Output Delivery System and reporting techniques

DYNAMICALLY CREATE MULTIPLE PDF FILES

Reply
N/A
Posts: 0

DYNAMICALLY CREATE MULTIPLE PDF FILES

can the dynamically created multiple flat files using FILEVAR= option be converted to PDF files?
SAS Super FREQ
Posts: 8,868

Re: DYNAMICALLY CREATE MULTIPLE PDF FILES

Posted in reply to deleted_user
According to the Doc, it says that FILEVAR doesn't work with the FILE PRINT ODS statement:

These arguments affect only listing output:
FOOTNOTES and NOFOOTNOTES
LINESIZE
PAGESIZE
TITLE and NOTITLES

Do not use these arguments:
DELIMITER=
DSD
_FILE_=
FILEVAR=
HEADER=
PAD


In a SAS Macro program, you could loop through a list of files, however and either do a PROC PRINT or a FILE PRINT ODS for each one, sending it to the PDF destination.

cynthia
N/A
Posts: 0

Re: DYNAMICALLY CREATE MULTIPLE PDF FILES

Posted in reply to Cynthia_sas
hi can you please send me the macro code which generates dynamically multiple PDF files?
Super Contributor
Posts: 260

Re: DYNAMICALLY CREATE MULTIPLE PDF FILES

Posted in reply to deleted_user
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 ;
OUTPUT ;
END ;
CARDS ;
c:\temp\sales2.txt
c:\temp\sales3.txt
RUN ;
ODS PDF FILE = "c:\temp\sales2.pdf" NEWFILE = BYGROUP ;
OPTION NOBYLINE ;
TITLE ;
PROC PRINT DATA = work.importedData LABEL NOOBS ;
VAR country year month product actual predict ;
BY changePDF ;
RUN ;
OPTION BYLINE ;
ODS PDF CLOSE ;

Regards.
Olivier
N/A
Posts: 0

Re: DYNAMICALLY CREATE MULTIPLE PDF FILES

hi oliver,
i am using SAS V8.2
Super Contributor
Posts: 260

Re: DYNAMICALLY CREATE MULTIPLE PDF FILES

Posted in reply to deleted_user
Then you don't have any STARTPAGE option in ODS PDF ? (I don't remember well what it was like in 8.2.)
SAS Super FREQ
Posts: 8,868

Re: DYNAMICALLY CREATE MULTIPLE PDF FILES

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.
cynthia
[pre]
*** the code;
%macro doby(byval=xxxxx);
ods pdf file="&byval..pdf";
proc print data=big_dsn;
where dsnvar = "&byval";
run;
ods pdf close;
%mend doby;

%doby(byval=Asia);
%doby(byval=Pacific);
%doby(byval=Canada);[/pre]
Ask a Question
Discussion stats
  • 6 replies
  • 316 views
  • 0 likes
  • 3 in conversation