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

Team, 

 

I have used the following code to and got the following plot. 

proc sgplot data=data;

vbar n/response=result  datalabel=result_1;

run;

Sairampulipati_0-1659355442973.png

Now I wanted to color those bars by cohort, if I am using the same code by adding after group=cohort after vbar n / then colors are getting applied but unfortunately datalabels are not getting applied. Can anyone help me with that. 

proc sgplot data=data;

vbar n/ group=cohort  response=result  datalabel=result_1;

run;

Sairampulipati_1-1659355718700.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Try adding option " groupdisplay=cluster "

 

proc summary data=sashelp.heart nway;
class ageatstart;
var weight;
output out=have sum=;
run;

data have;
 set have;
 if ageatstart<30 then flag=1;
  else if ageatstart<50 then flag=2;
   else flag=3;
run;

proc sgplot data=have;
vbarparm category=ageatstart response=weight/group=flag  datalabel=weight groupdisplay=cluster;
run;

Ksharp_0-1659360258895.png

 

View solution in original post

2 REPLIES 2
Ksharp
Super User

Try adding option " groupdisplay=cluster "

 

proc summary data=sashelp.heart nway;
class ageatstart;
var weight;
output out=have sum=;
run;

data have;
 set have;
 if ageatstart<30 then flag=1;
  else if ageatstart<50 then flag=2;
   else flag=3;
run;

proc sgplot data=have;
vbarparm category=ageatstart response=weight/group=flag  datalabel=weight groupdisplay=cluster;
run;

Ksharp_0-1659360258895.png

 

Sairampulipati
Fluorite | Level 6
Thank you so much.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 300 views
  • 0 likes
  • 2 in conversation