Dear SAS GRAPH community,
We are attempting to create specialized graphs using the following steps. Any ideas or help would be most appreciated.
step 1: We are creating 4 different box
plots from the following code which is using both proc template and proc
sgrender. Now we want to put these 4 boxplots adjacent to each
other on one sheet or one graphical output so that we can see all the 4
boxplots on one graph.
step 2 : The best way to show multiple
graphs on one output is to use proc greplay.Proc greplay uses the
grpahs that are produced and saved in a catalog.
Problem: How can I save the 4 graphs that
are produced in step 1 (using proc template and proc sgrender) to a catalog?
see the code below.
%let varlist=rebate std_bid plan_bid risk_score;
%macro chk;
%let j=0;
%do
%while(%scan(&varlist,&j+1,%str( )) ne %str( ));
%let j = %eval(&j+1);
%let var =
%scan(&varlist,&j,%str( ));
PROC SQL;
CREATE TABLE
WORK.&var.x1 AS
SELECT
t1.year,
t1.&var._min as min2,
t1.&var._p10 as min,
t1.&var._p25 as q1,
t1.&var._median as median,
t1.&var._mean as mean,
t1.&var._p75 as q3,
t1.&var._p90 as max,
t1.&var._max as max2,
t1.enrollment,
t1.state
FROM WORK.NEW t1
WHERE t1.year >= 2012
and t1._type_=32
and t1.state in (6,12,36,42)
ORDER BY t1.state, t1.year;
QUIT;
PROC TRANSPOSE DATA=WORK.&var.x1
OUT=WORK.&var.x2
(LABEL="Transposed Data
Set" drop=newlabel rename=(col1=&var))
PREFIX=Col
NAME=quantile
LABEL=newlabel ;
BY state year;
VAR min q1 median mean q3 max;
RUN;
/*Producing boxplots*/
proc template;
define statgraph
boxplotparm1;
begingraph;
entrytitle "&var Levels";
layout overlay;
boxplotparm y=&var x=area_yr stat=quantile/
meanattrs=(color=blue size=8px symbol=DiamondFilled weight=bold)
orient=horizontal;
endlayout;
endgraph;
end;
run;
proc sgrender data=work.&var.x4 template=boxplotparm1;
where enrollment>400000;
run;
%end;
%mend chk;
%chk;
You can use proc GSLIDE to put the image into a catalog, then play it in GREPLAY. But that is likely not your best option. In your macro you are creating separate graphs for each of the variables in the varlist.
You can use proc GSLIDE to put the image into a catalog, then play it in GREPLAY. But that is likely not your best option. In your macro you are creating separate graphs for each of the variables in the varlist.
Note that there are several caveats when it comes to using GREPLAY with images...
First, you have to use an old grseg-based proc (such as GSLIDE that Sanjay mentioned) along with annotate or iback, etc to get the image into a grseg. But you have to be very-very careful to get your size and proportions (x & y dimensions) of the original image just right, and then the size of your gslide just right (and annotate or iback in a way that doesn't stretch the image), and then the size of the final greplay output, in combination with the size of the custom areas where you greplay the images, must be "just right", for the images to look good.
If you stretch or distort the images out of proportion at any step along the way, the final graph can come out not looking so good.
Here's an example of a greplay dashboard, that was created by annotating images of graphs/indicators in gslides:
Thanks, Sanjay and Robert, for your quick and detailed responses. I'm working on incorporating your answers today. I will report success or ask more questions as I progress through the solution.
--Matt
Sanjay and Robert,
Thanks, again. I used Sanjay's third suggestion and it worked very well. I appreciate the help.
--Matt
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.
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.