DATA Step, Macro, Functions and more

PROC GBARLINE - specify legend

Reply
Contributor
Posts: 60

PROC GBARLINE - specify legend

Hi,

 

I have the below code that shows using uniform axis, the trended comparison between 2016 vs 2017. However, I'm trying to specify the legend into the chart but nothing works...any help would be appreciated. I would like two keys; one for '2017' and oanother for '2016'.

 

GOPTIONS RESET=ALL CBACK=WHITE BORDER HTITLE=12PT HTEXT=10PT;
SYMBOL INTERPOL=JOIN COLOR=BLACK VALUE=DOT;
LEGEND1 LABEL=(POSITION=(BOTTOM RIGHT) ) VALUE=('YR16' 'MTH_RENEW') ACROSS=1;
 TITLE 'RENEWALS 2016 VS 2017';
PROC GBARLINE DATA=CVMGEN.EME_RNWLS_2017 UNIFORMAXES;
   VBAR MTH_RENEW / SUMVAR=YR17 MAXIS=AXIS1  ;
   PLOT / SUMVAR=YR16;
RUN;
QUIT; 

Thanks

Super User
Posts: 13,338

Re: PROC GBARLINE - specify legend

Posted in reply to CamRutherford

You need to tell the procedure to use the legend.

 

Add

Legend=Legend1

to the plot options for the BAR.

 

Also in GBARLINE the syntax for the bar is BAR not Vbar

 

Or move to Proc Sgplot.

 

Contributor
Posts: 60

Re: PROC GBARLINE - specify legend

Posted in reply to CamRutherford

Tried it. Doesn't work.

 

It only givens me YR16

 

LEGEND1 LABEL=(POSITION=(BOTTOM RIGHT) ) VALUE=('YR16' 'YR17') ACROSS=1;

 TITLE 'GERMANY RENEWALS 2016 VS 2017';
PROC GBARLINE DATA=CVMGEN.EME_RNWLS_2017 UNIFORMAXES;
WHERE SBR_OFF_DESC = 'GERMANY';
   BAR MTH_RENEW / SUMVAR=YR17 MAXIS=AXIS1 RAXIS=AXIS2 LEGEND=LEGEND1 AUTOREF CLIPREF ;
   PLOT / SUMVAR=YR16 RAXIS=AXIS3 AUTOREF CLIPREF ;
RUN;
QUIT; 
Super User
Posts: 23,321

Re: PROC GBARLINE - specify legend

Posted in reply to CamRutherford

Can you move to SGPLOT? The quality of graphics are much better and the coding is simpler. 

 

 

Super User
Posts: 13,338

Re: PROC GBARLINE - specify legend

Posted in reply to CamRutherford

Without data we can't test code.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

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