BookmarkSubscribeRSS Feed
DR_Majeti
Quartz | Level 8

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.

2 REPLIES 2
Jay54
Meteorite | Level 14

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

DR_Majeti
Quartz | Level 8

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 7394 views
  • 5 likes
  • 2 in conversation