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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.