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;
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: