Data visualization with SAS programming

PROC SGPANEL: SERIES statement has no Y2AXIS option

Accepted Solution Solved
Reply
Trusted Advisor
Posts: 1,789
Accepted Solution

PROC SGPANEL: SERIES statement has no Y2AXIS option

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.


Accepted Solutions
Solution
‎07-13-2017 01:28 PM
SAS Super FREQ
Posts: 3,624

Re: PROC SGPANEL: SERIES statement has no Y2AXIS option

[ Edited ]

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


All Replies
Solution
‎07-13-2017 01:28 PM
SAS Super FREQ
Posts: 3,624

Re: PROC SGPANEL: SERIES statement has no Y2AXIS option

[ Edited ]

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;

 

Trusted Advisor
Posts: 1,789

Re: PROC SGPANEL: SERIES statement has no Y2AXIS option

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.

Trusted Advisor
Posts: 1,789

Re: PROC SGPANEL: SERIES statement has no Y2AXIS option

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

 

Thanks @Rick_SAS and @ChrisHemedinger.

Trusted Advisor
Posts: 1,789

Re: PROC SGPANEL: SERIES statement has no Y2AXIS option

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. Smiley Sad

 

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.

 

 

SAS Employee
Posts: 6

Re: PROC SGPANEL: SERIES statement has no Y2AXIS option

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;

 

Trusted Advisor
Posts: 1,789

Re: PROC SGPANEL: SERIES statement has no Y2AXIS option

[ Edited ]

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.

Trusted Advisor
Posts: 1,789

Re: PROC SGPANEL: SERIES statement has no Y2AXIS option

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

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 327 views
  • 4 likes
  • 3 in conversation