Hi , I am creating waterfall plot and a bar chart in one panel , where in both the plots the treatments are same for the legend. I don't want to duplicate the same treatments for the two plots in the legend. How can i suppress or exclude the duplicate treatments from the legend. I am using below code to create the plots. Attached is the plot for reference
proc sgplot data=fin nowall noborder nocycleattrs;
format trtpn arm.;
styleattrs datacolors=(blue yellow green red purple) datacontrastcolors=(blue yellow green red purple) axisextent=data;
symbolchar name=mystar char='002a'x / voffset= -0.5 scale=7;
vbarparm category=usubjid response=chgsld / group=trtpn datalabel=chgsld dataskin=pressed
datalabelattrs=(size=8 weight=bold) clusterwidth=1;
vbarparm category=usubjid response=chgbm / group=trtpn datalabel=chgbm y2axis dataskin=pressed
/*fillattrs=(color= cxcfcf7f)*/;
scatter x=usubjid y=CRR / markerattrs=(symbol=mystar color= green size=3);
/* refline 20 -30 / lineattrs=(pattern=shortdash);*/
xaxis display=none colorbands=odd colorbandsattrs=(transparency=0.6);
yaxis label="Change from baseline in Total SLEDAI score" values=(40 to -40 by -10) offsetmax=0.55 labelpos=datacenter offsetmin=0;
y2axis label="Change from baseline in Biomarker" values=(90 to -90 by -15) offsetmin=0.5 offsetmax=0.02 labelpos=datacenter;
keylegend / exclude=("Change from Baseline") title='' border;
run;
Maybe give the plots that you want to include in the legend a name and then only include those in the key legend instead?
FYI - this is a case where formatting the code for legibility really helps. Your exclude statement confuses me as there's no other reference to that item in the code.....
@ramtejdasari wrote:
Hi , I am creating waterfall plot and a bar chart in one panel , where in both the plots the treatments are same for the legend. I don't want to duplicate the same treatments for the two plots in the legend. How can i suppress or exclude the duplicate treatments from the legend. I am using below code to create the plots. Attached is the plot for reference
proc sgplot data=fin nowall noborder nocycleattrs;
format trtpn arm.;
styleattrs datacolors=(blue yellow green red purple) datacontrastcolors=(blue yellow green red purple) axisextent=data;
symbolchar name=mystar char='002a'x / voffset= -0.5 scale=7;
vbarparm category=usubjid response=chgsld / group=trtpn datalabel=chgsld dataskin=pressed
datalabelattrs=(size=8 weight=bold) clusterwidth=1;
vbarparm category=usubjid response=chgbm / group=trtpn datalabel=chgbm y2axis dataskin=pressed
/*fillattrs=(color= cxcfcf7f)*/;
scatter x=usubjid y=CRR / markerattrs=(symbol=mystar color= green size=3);
/* refline 20 -30 / lineattrs=(pattern=shortdash);*/
xaxis display=none colorbands=odd colorbandsattrs=(transparency=0.6);
yaxis label="Change from baseline in Total SLEDAI score" values=(40 to -40 by -10) offsetmax=0.55 labelpos=datacenter offsetmin=0;
y2axis label="Change from baseline in Biomarker" values=(90 to -90 by -15) offsetmin=0.5 offsetmax=0.02 labelpos=datacenter;
keylegend / exclude=("Change from Baseline") title='' border;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.