Hello,
my legend does not have any colors to match with the bargraph. not sure how to fix it
output:
code:
proc sgplot data=graph;
vbar var/response=varn group=txt groupdisplay=cluster;
label varn='% of Patients'
var=''
txt='Visit Time';
legenditem type=FILL name='Baseline' /label='Baseline (N=&two1n)' ;
legenditem type=FILL name='Usage' /label='60-Month followup (N=&two2n)';
keylegend "Baseline" "Usage";
run;
Also use attrmap top be sure that colors "match": https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p18q268a3zxcl3n11lnnnq4cme8r.htm
data attrmapfruit;
retain linecolor "black";
input id $ value $ fillcolor $;
datalines;
sex F red
sex M blue
;
run;
proc sgplot data=sashelp.class dattrmap=attrmapfruit;
vbar age/response=height group=sex groupdisplay=cluster attrid=sex;
label height='height label'
sex='sex label'
age='age label';
legenditem type=FILL name='F' / FILLATTRS=(color=red) label='F label';
legenditem type=FILL name='M' / FILLATTRS=(color=blue) label='M label' ;
keylegend "F" "M";
run;
Bart
Also use attrmap top be sure that colors "match": https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p18q268a3zxcl3n11lnnnq4cme8r.htm
data attrmapfruit;
retain linecolor "black";
input id $ value $ fillcolor $;
datalines;
sex F red
sex M blue
;
run;
proc sgplot data=sashelp.class dattrmap=attrmapfruit;
vbar age/response=height group=sex groupdisplay=cluster attrid=sex;
label height='height label'
sex='sex label'
age='age label';
legenditem type=FILL name='F' / FILLATTRS=(color=red) label='F label';
legenditem type=FILL name='M' / FILLATTRS=(color=blue) label='M label' ;
keylegend "F" "M";
run;
Bart
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.