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
Onyx | Level 15

#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
Onyx | Level 15

#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



sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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