BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PaigeMiller
Diamond | Level 26

I have created some very nice plots using PROC SGPLOT, using the several SERIES statements, some of which use the Y2AXIS option, to generate line plots with 2 different vertical axes. Great, exactly what I wanted.

 

Then, I wanted 4 of these plots on a page (2 rows and 2 columns), so I switch to PROC SGPANEL which will produce this 2x2 matrix of plots, but then I discover there is no Y2AXIS option on the SERIES statement.

 

So, my question ... can someone recommend a workaround or alternative that can give me two different vertical axis scales in PROC SGPANEL?

 

I know I can do this in traditional SAS/GRAPH with templates in PROC GREPLAY, but since my code is already written in ODS GRAPHICS, I'd prefer to stay in ODS Graphics if possible.

--
Paige Miller
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Hi Paige,

Depending on your ODS destination, you might be able to use ODS LAYOUT GRIDDED on the original SGPLOT output. This statement was added in SAS 9.4m1. Some simple examples are:

Run the following simple example to get an idea how it works, then let us know whether this might suit your needs:

 

ods graphics / width=4in height=2in;
ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
   where stock="IBM";
   series x=date y=open;
   series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
   where stock="Intel";
   series x=date y=open;
   series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
   where stock="Microsoft";
   series x=date y=open;
   series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

 

View solution in original post

7 REPLIES 7
Rick_SAS
SAS Super FREQ

Hi Paige,

Depending on your ODS destination, you might be able to use ODS LAYOUT GRIDDED on the original SGPLOT output. This statement was added in SAS 9.4m1. Some simple examples are:

Run the following simple example to get an idea how it works, then let us know whether this might suit your needs:

 

ods graphics / width=4in height=2in;
ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
   where stock="IBM";
   series x=date y=open;
   series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
   where stock="Intel";
   series x=date y=open;
   series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
   where stock="Microsoft";
   series x=date y=open;
   series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

 

PaigeMiller
Diamond | Level 26

Thanks, @Rick_SAS, this looks exactly like what I want to do. Ideally, the output is via ODS POWERPOINT. I'll take a crack at it and see if I can get it to work.

--
Paige Miller
PaigeMiller
Diamond | Level 26

Well that was easy! Chris's example works fine with ODS POWERPOINT.

 

Thanks @Rick_SAS and @ChrisHemedinger.

--
Paige Miller
PaigeMiller
Diamond | Level 26

Now I have found that I can produce one such 2x2 matrix of plots using SGPLOT and have it show up in Powerpoint via ODS POWERPOINT. Works great.

 

But I actually want seven different 2x2 matrices of plots, one on each page of a POWERPOINT document, and SAS crashes when I try this via a macro %DO loop to loop over all seven variables of interest. 😞

 

If I re-write the same loop to create seven different Powerpoint files, with one plot each, no errors and no crashes.

 

Performing both of the above attempts to output the plots via ODS HTML, no error and no crashes either way.

 

 

--
Paige Miller
DavidK_SAS
SAS Employee

The below "unmacroized" SAS code produces expected output with 9.4M4.  Sorry, the discussion software won't allow me to attach crash.pptx.

 

-- David Kelley

   Output Delivery and Reporting

   SAS

 

ods graphics / width=4in height=2in;


ods powerpoint file = "crash.pptx";

ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
where stock="IBM";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Intel";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Microsoft";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

ods powerpoint startpage=now;

ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
where stock="IBM";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Intel";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Microsoft";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

ods powerpoint startpage=now;

ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
where stock="IBM";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Intel";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Microsoft";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

ods powerpoint startpage=now;

ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
where stock="IBM";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Intel";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Microsoft";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

ods powerpoint startpage=now;

ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
where stock="IBM";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Intel";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Microsoft";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

ods powerpoint startpage=now;

ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
where stock="IBM";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Intel";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Microsoft";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

ods powerpoint startpage=now;

ods layout gridded columns=2 advance=table;

proc sgplot data=sashelp.stocks;
where stock="IBM";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Intel";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
where stock="Microsoft";
series x=date y=open;
series x=date y=volume / y2axis;
run;
proc sgplot data=sashelp.stocks;
vbox open / category=stock;
run;

ods layout end;

ods powerpoint close;

 

PaigeMiller
Diamond | Level 26

ods powerpoint startpage=now;

 

I think that's what I might have been missing.

 

Of course, my company is still using 9.4M2, so maybe that's the problem.

 

I will try these out tomorrow at work.

--
Paige Miller
PaigeMiller
Diamond | Level 26

It appears that the STARTPAGE option of the ODS POWERPOINT command does not exist in my version SAS 9.4 TS1M2 😞

 

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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