BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
HitmonTran
Pyrite | Level 9

Hello,

 

my legend does not have any colors to match with the bargraph. not sure how to fix it

 

output:

HitmonTran_1-1695704904509.png

 

 

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

#Maxim1

 

https://documentation.sas.com/doc/en/pgmsascdc/v_043/grstatproc/p0hc32jtfqoy1fn1h5i38q8v9py2.htm#n00...

 

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; 

yabwon_0-1695709835302.png

 

 

 

 

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

1 REPLY 1
yabwon
Amethyst | Level 16

#Maxim1

 

https://documentation.sas.com/doc/en/pgmsascdc/v_043/grstatproc/p0hc32jtfqoy1fn1h5i38q8v9py2.htm#n00...

 

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; 

yabwon_0-1695709835302.png

 

 

 

 

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 889 views
  • 0 likes
  • 2 in conversation