As you know by now, I'm just learning about plotting!
I have developed a line plot of a mean across timepoints, with bars for 95% confidence interval. (PROC GPLOT) I'm trying to create a very simple legend, simply indicating that the red line is treatment group 1 and the blue line is treatment group 2. Everything I try generates stuff that I don't want.
Is there an easy way to populate the legend with something simple like this?
--- Placebo ---- Study Drug
Here is my code (I found it online and it does exactly what I need). Mean1 is the mean per session, Thresh1 contains LCM and UCM.
proc gplot data=prep5;
plot thresh1*session mean1*session thresh2*session mean2*session / overlay haxis=axis1 vaxis=axis2
/*legend=legend1*/;
title1 h=8pt color=black font='courier' J=L "&titlel1";
title2 h=8pt color=black font='courier' J=L "Protocol: &titlel2 Page 1 of 1";
title5 h=8pt color=black font='courier' J=C "&titlel5";
title6 h=8pt color=black font='courier' J=C "&titlel6";
title7 h=8pt color=black font='courier' J=C "&titlel7";
run;
I often use title or footnote statements to 'fake' a legend, to get one exactly like I want it.
In your case, you could use something like the following:
title8 c=blue "--- Placebo" c=red " --- Study Drug";
If you're just learning graphing in SAS I would strongly recommend learning SG procedures instead of GPLOT procedures.
There is more on GPLOT currently - because it's really really old. SG is available in more versions of SAS, you have more control over your graphics and it produces much better quality graphics.
Thanks, Cynthia. I went through Wendi's paper and was able to come up with something that'll be good enough.
I will definitely take yours and Reeza's advice and learn about SGPLOT!
I often use title or footnote statements to 'fake' a legend, to get one exactly like I want it.
In your case, you could use something like the following:
title8 c=blue "--- Placebo" c=red " --- Study Drug";
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.