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.
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.
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.
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.
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.