I am using GCHART to produce clustered stacked bar chart using the following code. I want to show data labels (percentage of total as rounded without % sign) of individual components within a vertical bar along with letter grouping that is available in the dataset as an individual column with letters for each observation. The first issue I am not able to resolve is that what changes I need to make in the following code to make it rounded percentages without % sign. I have used Inside=subpct option. I am using 9.3 TS1M2.
Here is the code!
length group $15 midpoint $10 Labels $3;
retain xsys ysys '2' color 'black' when 'a';
/* Generate vertical bar chart */
goptions htext=1.6 htitle=2 Ftitle="Times New Roman" Ftext="Times New Roman";
/*ods listing image_dpi=450;
ods html close;
ods graphics /noborder imagefmt=jpeg ANTIALIASMAX=6300 ; */
Proc gchart data=DM;
vbar Cultivar / discrete noframe
raxis=axis1 maxis=axis2 gaxis=axis3 legend=legend1;
axis1 label=(a=90 f="Times New Roman" h=4pct "Dry matter (Mg/ha)" ) value=(f="Times New Roman" h=3pct) order=0 to 12 by 2 minor=none;
axis2 label=none value=(f="Times New Roman" h=2pct);
axis3 label=none value=(f="Times New Roman" h=2.7pct);
legend1 position=(top left inside) across=1 order= ("PL" "LL" "Head" "FL" "Stem") noframe label=none value=(f="Times New Roman" j=l) shape=bar(5,2);
Thanks for the help!
Message was edited by: Bhupinder Farmaha
How are you creating the variable called 'labels' (that you use in the annotated text=labels)?
If you have a numeric variable that has percent values in it (such as foo=.20 for 20%), then you can set the annotated text as follows...
If you *do* want the % sign, then apply a percent format, something like:
If you do *not* want the % sign in the annotated text, then multiply by 100, something like ...
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.