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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 647 views
  • 0 likes
  • 2 in conversation