BookmarkSubscribeRSS Feed
DaLack
Calcite | Level 5

I want to plot the results of two quantile regressions. The output of my quantile regression was a grouped variable "quantile" plus the corresponding values. I tried to create a graph with the following code in SAS 9.4:

 

ods graphics on / labelmax=42100 antialiasmax=42100;
proc sgplot data=data1;
scatter x=Var1 y=Var2;
series x=Var1 y=Var3 / group=quantile legendlabel="Gew" name="G";
series x=Var1 y=Var4 / group=quantile lineattrs=(pattern=dot) legendlabel="OhneGew" name="OG";
keylegend "G" "OG" / location=inside position=topleft title="Quantile" titleattrs=(weight=bold) across=3;
run;
ods graphics off;

The resulting plot is attached. My aim was to label the percentiles in the legend. The first row in the legend should begin with "Gew" and should belong to the first three percentiles (solid line). The second one should start with "OhneGew" and should belong to the other three percentiles (dotted line). Therefore I used the keylegend statement along with the legendlabel statement. But as a result, I only get a legend without the required legendlabels "Gew" and "OhneGew". 

 

How can I modify the legend in order to get the legendlabels?

Many thanks in advance.


SGPlot.png
1 REPLY 1
Rick_SAS
SAS Super FREQ

I would try using two KEYLEGEND statements. You can use the POSITION= option to place the legends.

For example use POSITION=TOPLEFT for the first legend and POSITION=TOPRIGHT for the second.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 1 reply
  • 828 views
  • 0 likes
  • 2 in conversation