BookmarkSubscribeRSS Feed
deleted_user
Not applicable
can the dynamically created multiple flat files using FILEVAR= option be converted to PDF files?
6 REPLIES 6
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
hi can you please send me the macro code which generates dynamically multiple PDF files?
Olivier
Pyrite | Level 9
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
deleted_user
Not applicable
hi oliver,
i am using SAS V8.2
Olivier
Pyrite | Level 9
Then you don't have any STARTPAGE option in ODS PDF ? (I don't remember well what it was like in 8.2.)
Cynthia_sas
SAS Super FREQ
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]

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1662 views
  • 0 likes
  • 3 in conversation