Data visualization with SAS programming

Can we get second y-axis using "Proc SGpanel" ?

Reply
Contributor
Posts: 64

Can we get second y-axis using "Proc SGpanel" ?

Hi All,

Can we get second y-axis using "Proc SGpanel" ?

By using SGPlot we can achieve by it by "y2axis" statement but how do we get it by using SGPanel procedure.

is it possible ?

Thanks in advance.

SAS Super FREQ
Posts: 1,134

Re: Can we get second y-axis using "Proc SGpanel" ?

You can get an axis on the right side, but it has to be the same as the Y axis.  Y2AXIS option on the plot statement is not supported in SGPANEL.

This is where you will need to move up to GTL.  Bar Chart and other BASIC plot statements are allowed in Layout DataLattice.  But not statements that need data summarization like Histogram, etc.  If you need those, you will have to summarize (or min) the data yourself.  GTL code attached:

Should work with SAS 9.3.  But Columnweight=Proportional needs SAS 9.4.

proc template;

  define statgraph Y2Panel;

    begingraph;

      entrytitle 'Mileage and Horsepower by Origin and Type';

      layout datalattice columnvar=origin / headerlabeldisplay=value columnweight=proportional

             columnaxisopts=(display=(tickvalues) discreteopts=(tickvaluefitpolicy=none))

             rowaxisopts=(offsetmin=0)

             row2axisopts=(offsetmin=0);

        layout prototype;

           barchart x=type y=mpg_city / discreteoffset=-0.2 name='a'

                   barwidth=0.4 stat=mean fillattrs=graphdata1;

           barchart x=type y=horsepower / discreteoffset=0.2 barwidth=0.4

                   stat=mean yaxis=y2 fillattrs=graphdata2 name='b';

        endlayout;

        sidebar / spacefill=false;

          discretelegend 'a' 'b';

        endsidebar;

      endlayout;

    endgraph;

  end;

run;

ods html close;

ods listing;

ods graphics / reset width=8in height=4in imagename='Y2Panel';

proc sgrender data=sashelp.cars(where=(type ne 'Hybrid')) template=Y2Panel;

run;

Y2Panel.png

Contributor
Posts: 64

Re: Can we get second y-axis using "Proc SGpanel" ?

Hi Sanjay,

Thank you for your advice, I have idea of GTL and i am using it to produce Yaxis on right side. Just want to know is there any possibility of getting it by SGPANEL.

Thanks once again for you answer and advice.

Ask a Question
Discussion stats
  • 2 replies
  • 1892 views
  • 4 likes
  • 2 in conversation