BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mathal
SAS Employee

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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.

  1. You could write the graphs into ODS Documents, and then play them onto ODS Layout.
  2. You could do the loop outside the macro, and then play each graph into an ODS Layout directly.
  3. You could set your data up so you have the variables in the varlist as a class variable in the data, with box data for each value.  Then, you could use a GTL DataPanel or DataLattice with this class variable, and create a grid, all within GTL.

View solution in original post

4 REPLIES 4
Jay54
Meteorite | Level 14

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.

  1. You could write the graphs into ODS Documents, and then play them onto ODS Layout.
  2. You could do the loop outside the macro, and then play each graph into an ODS Layout directly.
  3. You could set your data up so you have the variables in the varlist as a class variable in the data, with box data for each value.  Then, you could use a GTL DataPanel or DataLattice with this class variable, and create a grid, all within GTL.
GraphGuy
Meteorite | Level 14

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:

http://robslink.com/SAS/democd26/kpidash.htm

http://robslink.com/SAS/democd26/kpidash_info.htm

mathal
SAS Employee

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

mathal
SAS Employee

Sanjay and Robert,

Thanks, again. I used Sanjay's third suggestion and it worked very well. I appreciate the help.

--Matt


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
  • 4 replies
  • 1375 views
  • 3 likes
  • 3 in conversation