BookmarkSubscribeRSS Feed
CHELS
Obsidian | Level 7

Trying to create something similar to the following whereby the legend for the red and green line is within the box. 

 

Untitled.png

 

 

However, using the code I have, the legend for the line still appears by itself:

 

proc univariate data=Score noprint plot;
var Predp;
class AAA;
histogram Predp /
kernel (k=normal color=green c = 0.75 l=1);
inset n ='N' (comma6.0) mean ='Mean' (6.2)
median ='Median' (6.2) mode ='Mode'(6.2)/ position=NE;
run;

 

Untitled1.png

 

5 REPLIES 5
Rick_SAS
SAS Super FREQ

I see you are using 

CLASS AAA;

Is this part of a comparative histogram that appears in a panel?

 

CHELS
Obsidian | Level 7

Yes, so there are two stacked histograms and I want to compare between the two. 

Rick_SAS
SAS Super FREQ

But then where do you want the legend? 

 

My advice is to suppress the legend by using the NOCURVELEGEND option and then add the kernel C= value to the inset. Here is an example:

 

proc univariate data=Sashelp.class noprint plot;
var height;
class sex;
histogram height / NOCURVELEGEND
        kernel (k=normal color=green c = 0.75 l=1);
inset n ='N' (comma6.0) mean ='Mean' (6.2)
        median ='Median' (6.2) mode ='Mode'(6.2) 
        KERNEL(C) / position=NE;
run;
CHELS
Obsidian | Level 7

I want the legend for the curve to be inside the legend box together with other estimates (N, Mean, Median etc.). Actually, it doesn't make too much of a difference where that curve legend is but I am trying to follow an output template that requires it to be inside the box. 

PGStats
Opal | Level 21

You could go for proc sgplot (more graphing options, fewer estimation options)

 

proc sgplot data=sashelp.heart;
histogram cholesterol;
density cholesterol / group=sex type=kernel;
keylegend / position=topright location=inside across=1;
run;

SGPlot6.png

PG

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 2446 views
  • 2 likes
  • 3 in conversation