BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
emiliepcantin
Calcite | Level 5

Hi, I would like to format the datalabel without formatting the axis values. I have used a different variable to store the format, but it does not seem to work when using group=. Here is my code.

proc format;
   picture thousand low-high='000,009.99 K$' ;
   picture thousandRound low-high='000,009' ;
run;

data TeamMap;
input id $ value & :$25. fillcolor :$8.;
datalines;
Team Atlanta        CX00061c 
Team Baltimore      cx000d38 
Team Boston         CX001455 
Team California     CX001b71 
Team Chicago        CX00228d 
Team Cincinnati     Cx0029aa 
Team Cleveland      CX0030c6 
Team Detroit        CX0037e2 
Team Houston        CX003eff 
Team Kansas City    CX1c53ff 
Team Los Angeles    CX3868ff 
Team Milwaukee      CX557efe 
Team Minneapolis    CX7193ff 
Team Montreal       CX8da9ff 
Team New York       CXa9beff 
Team Oakland        CXc6d4ff 
Team Philadelphia   CXe2e9ff 
Team Pittsburgh     CXf6f8ff
Team San Diego      CXfff6f8
Team San Francisco  CXffdde4
Team Seattle        CXffc3d0
Team St Louis       CXffaabd
Team Texas          CXff91a9
Team Toronto        CXff7795
;
run;

data have;
retain Team Salary Salary_F Salary_F2;
	set sashelp.baseball;
	salary_F = salary;
	salary_F2 = salary;
	format salary_F thousand. salary_f2 thousandRound.;
run;

proc sgplot data=have dattrmap=TeamMap noautolegend;
    vbar Team / response=salary_F2 datalabel=salary_F group=Team attrid=Team outlineattrs=(color=black);
	xaxis discreteorder=data;
run;

If I don't specify a variable, I don't have the right format but the datalabel is displayed. If I specify a variable, the datalabel is not showing unless I remove the group= option. I do need the group= option to specify the fill color using a dattrmap. 

 

Any solution that allows me to use two different formats plus a specific fill color maping is welcome.

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

On the VBAR statement, set GROUPDISPLAY=CLUSTER, and the labels should appear as you want.

 

Hope this helps!

Dan

View solution in original post

3 REPLIES 3
ballardw
Super User

The reason why is appearing in your log. You should see something like:

NOTE: DATALABEL= option is supported with GROUP= option only when GROUPDISPLAY=CLUSTER option is
      specified. The label will not be drawn.

So you need a slightly different plot.

Consider:

proc summary data=sashelp.baseball nway;
   class team;
   var salary;
   output out=summary sum=salary_f2;
run;

proc sgplot data=summary dattrmap=TeamMap noautolegend;
    vbarbasic Team / response=salary_F2  
            group=Team attrid=Team outlineattrs=(color=black)
            
   ;
   scatter x=team y=salary_f2 /datalabel ;
   format salary_f2 thousandround.;
	xaxis discreteorder=data;
run;

which uses summary to the sums of salaries by team and with a VBARBASIC plot you can overlay another.

Size and color ranges mean that, at least with my defaults, some of the text isn't readable due to the segment colors and spacing.

But this may get you started.

 

DanH_sas
SAS Super FREQ

On the VBAR statement, set GROUPDISPLAY=CLUSTER, and the labels should appear as you want.

 

Hope this helps!

Dan

emiliepcantin
Calcite | Level 5
That is a good solution for my problem ! Thank you 🙂

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 2009 views
  • 0 likes
  • 3 in conversation