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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1473 views
  • 0 likes
  • 3 in conversation