Reputation: 1023
When generating several charts as output, SAS graph procedures normally start to name them by index, eg: gchart1.png gchart2.png gchart3.png.
Is it possible to override these names and instead specify a variable containing the names?
For example if the multiple charts are generated with a 'by' statement, can you use the same variable used in the 'by' statement to also create the names of the generated charts?
The advantage here is if you add or remove 'by' variables, the names of the existing charts remain the same if they carry a real name, but if they're using an adhoc index, they could all shift.
If this is not possible, what do people do? Do you just allow the index names to be used and then write more code to go back and rename the charts to the more meaningful names?
Here's the reproducible example. Instead of the charts being called gchart1.png gchart2.png, it would be better if they had real names such as the 'by' variable names:
/* Specify the ODS output path */
filename odsout ".";
/* Create data set from sashelp.prdsale */
data prdsummary;
set sashelp.prdsale;
where year=1993 and (country = "GERMANY" or country = "CANADA")
and region="EAST" and division="CONSUMER" and
(product="SOFA" or product="TABLE" or product="BED");
run;
/* Sort the data set by quarter */
proc sort data=work.prdsummary;
by quarter;
run;
/* Close the currently open ODS destinations */
ods _all_ close;
/* Generate the graph */
ods html path=odsout file="sales.htm" style=seaside;
goptions reset=all border;
title1 "1993 Sales";
proc gchart data=prdsummary(where=(year=1993));
vbar3d country / sumvar=actual subgroup=product sum;
by quarter;
run;
quit;
ods html close;
ods html; /* Not required in SAS Studio */
Upvotes: 1
Views: 136
Reputation: 2776
Using the name=
option should allow you to do this.
proc gchart data=prdsummary(where=(year=1993));
vbar3d country / sumvar=actual subgroup=product sum name="sales_quarter#byval(quarter)";
by quarter;
run;
quit;
This will names the files sales_quarter1.png, sales_quarter2.png and so on...
Upvotes: 1