Data visualization with SAS programming

Why does the label option after the refline statement not work in the PROC sgpanel.

Accepted Solution Solved
Reply
Contributor
Posts: 60
Accepted Solution

Why does the label option after the refline statement not work in the PROC sgpanel.

Hi there,

 

I want to generate a panel of histogram by using PRCO SGPANEL. Please see my codes below. The output is attached. Why the lable='median' does not show beside each line in the plot? Thank you in advance. 

 

proc sgpanel data=test;
panelby group;
histogram q2;
refline medianline_q2/axis=x lineattrs=(color=red) label="median";
run;

 

Attachment

Accepted Solutions
Solution
a month ago
SAS Super FREQ
Posts: 864

Re: Why does the label option after the refline statement not work in the PROC sgpanel.

Ah..it's drawing the label multiple times. Sorry about that. Instead of RETAINing the value, add the value to the LABEL column only once per cell value. That should do it.

 

Thanks!
Dan

View solution in original post


All Replies
SAS Super FREQ
Posts: 864

Re: Why does the label option after the refline statement not work in the PROC sgpanel.

When your refline values come from a variable, your labels must also come from a variable. Try RETAINing the "median" value in a variable and referencing that variable from the LABEL option.

 

Hope this helps!

Dan

Contributor
Posts: 60

Re: Why does the label option after the refline statement not work in the PROC sgpanel.

Hi Dan,

 

Thanks for your solution. I tried to create a variable with value='Median' then apply it to the Label option..However, the output looks a little ungly. Do do have any way to refine the font of the label? See the attached plot. 

 

Thank you!

 

Attachment
Solution
a month ago
SAS Super FREQ
Posts: 864

Re: Why does the label option after the refline statement not work in the PROC sgpanel.

Ah..it's drawing the label multiple times. Sorry about that. Instead of RETAINing the value, add the value to the LABEL column only once per cell value. That should do it.

 

Thanks!
Dan

Contributor
Posts: 60

Re: Why does the label option after the refline statement not work in the PROC sgpanel.

Works perfect!  Thank you!

Post a Question
Discussion Stats
  • 4 replies
  • 79 views
  • 0 likes
  • 2 in conversation