BookmarkSubscribeRSS Feed
rab24
Calcite | Level 5
I am using EG3 to create a large series of graphs of which I only need some. Rather than 1 complete PDF with all graphs, is there a way I can automate production of these graphs into separate PDF files that have file names generated by the "group by" variables used in the graph code?

In essence, I have:

Myfile.pdf
Page 1) Tom graph
Page 2) Rob graph
Page 3) Jan graph

but I need:
Tom.pdf
Rob.pdf
Jan.pdf

Where Tom, Rob, and Jan are possible values in my Groub By variable.
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi...if you use a code node in EG, you can "sort" of generate the separate PDF files. There's an upside and a downside. The upside is that if you use NEWFILE=BYGROUP, the files get created automatically. The downside is that you can only "sort of" control the name of the file. For example, with the attached code:
[pre]
proc sort data=sashelp.prdsale out=prdsale;
by division prodtype;
run;

options orientation=landscape topmargin=1in bottommargin=1in
rightmargin=1in leftmargin=1in nodate number pageno=1;
run;

ods pdf file="c:\temp\GRFBY1.pdf" newfile=bygroup;

GOPTIONS reset=all device=actximg;

PROC GCHART DATA=prdsale;
title 'The Graph Title';
VBAR3D region / SUMVAR=actual
GROUP=product
SHAPE=BLOCK
FRAME TYPE=SUM
PATTERNID=MIDPOINT;
BY division prodtype;
format actual dollar12.2;
RUN; QUIT;

ods _all_ close;
title;
footnote;
ods listing;

[/pre]

If the SAS dataset has 4 BY groups, then the PDF output files will be named: GRFBY1.PDF, GRFBY2.PDF, GRFBY3.PDF, GRFBY4.PDF -- which means you can control the "beginning" part of the name, but NEWFILE= option wants to number the output files by incrementing the right-most number in the starting file name by 1 for each BYGROUP (in this example). Of course, after the files were created in c:\temp, you could go and issue a RENAME to name them what you wanted.

Your only other alternative would be to "macroize" the program to produce a single BY group -- and then you can control the name of every BY group's file -- when you invoke the macro program for each group. And then you could call the files Tom.PDF, Rob.PDF and Jan.PDF. (or whatever else you wanted).

Good luck!
cynthia

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
  • 1 reply
  • 612 views
  • 0 likes
  • 2 in conversation