Data visualization with SAS programming

Plot overlay with same y-axis-scale, Help please. Thank you

Reply
Frequent Contributor
Posts: 95

Plot overlay with same y-axis-scale, Help please. Thank you

Hi All

I am interested in plotting graphs using same scale! The below code plots two series using overlay however each series is given a different scale on Y1 and Y2 axis. Please can you help  on how we modify the code to have both series of data on the same scale?

Context:

I need to make sure the p-scores (probabilities) reflect actual response rates in our campaign history. These plots help us with that activity. Many Thanks

Here is the code...

%_eg_conditional_dropds(WORK.SORTTempTableSorted);

/* -------------------------------------------------------------------

   Sort data set WORK.LIFT2

   ------------------------------------------------------------------- */

PROC SORT

       DATA=WORK.LIFT2(KEEP=decile resprate mean_score)

       OUT=WORK.SORTTempTableSorted

       ;

       BY decile;

RUN;

SYMBOL1

       INTERPOL=JOIN

       HEIGHT=10pt

       VALUE=NONE

       LINE=1

       WIDTH=2

       CV = _STYLE_

;

SYMBOL2

       INTERPOL=JOIN

       HEIGHT=10pt

       VALUE=NONE

       LINE=1

       WIDTH=2

       CV = _STYLE_

;

Legend1

       FRAME

       ;

Axis1

       STYLE=1

       WIDTH=1

       MINOR=NONE

;

Axis2

       STYLE=1

       WIDTH=1

       MINOR=NONE

;

Axis3

       STYLE=1

       WIDTH=1

       MINOR=NONE

       LABEL=NONE

;

TITLE;

TITLE1 "Line Plot";

FOOTNOTE;

FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";

PROC GPLOT DATA = WORK.SORTTempTableSorted

;

PLOT resprate * decile  /

OVERLAY

       VAXIS=AXIS1

       HAXIS=AXIS2

       HREVERSE

FRAME  LEGEND=LEGEND1

;

PLOT2 mean_score * decile  = 2  /

OVERLAY

       VAXIS=AXIS1

OVERLAY

       LEGEND=LEGEND1

;

run; quit;

SAS Employee
Posts: 967

Re: Plot overlay with same y-axis-scale, Help please. Thank you

By default, the gplot axes auto-scale to fit the data ... if you plot slightly different data, the auto-scale axes will be slightly different.

Since you want the axes to be exactly the same, you can hard-code the range of the axes, rather than letting them auto-scale.  Since you use axis1 for both the left & right axes, you will only need to hard-code it in the axis1 statement.  Something like ...

axis1 order=(0 to 100 by 20) ...

Frequent Contributor
Posts: 95

Re: Plot overlay with same y-axis-scale, Help please. Thank you

Thank You Robert...

Ask a Question
Discussion stats
  • 2 replies
  • 446 views
  • 0 likes
  • 2 in conversation