ok, now I don't understand what do you mean by "why does the data label not show anymore?" - there are data labels ( "XX (YY%)" ) on the plot, what other data label do you expect ?
Bart
In sgplot there are datalabel and a seglabel statements, the seglabels label the segements, that is what we did. The datalabel labels the totals per bar, like bar 1 will have a total of 226 placed at the top of the bar. That is what I mean
I think this should be it:
data have4;
set have3;
by period visit;
if first.visit then tot=0;
pos= tot + SumDosis/2;
tot + SumDosis;
if last.visit then /* this is to avoid ugly warnings in the log */
do;
total=tot;
vst=visit;
end;
length N_percentage $15 ;
N_Percentage=catx(" ", SumDosis, "(", put(percentage, percent8.2), ")");
keep period drug visit SumDosis N_percentage pos total vst;
run;
ods graphics / width=1200px height=1000px;
proc sgpanel data = have4;
styleattrs datacolors=(
CXfc8d59
CXfdbb84
CXfdd49e
CXfee8c8
CXfff7ec
CXffffff
CXfff7fb
CXece7f2
CXd0d1e6
CXa6bddb
CX74a9cf
);
panelby period / columns=3 novarname noborder;
vbarparm category=vst response=total / datalabel=total seglabel
OUTLINE OUTLINEATTRS=(color=black THICKNESS=1) NOFILL
;
vbarparm category=visit response=SumDosis / group=drug grouporder=data groupdisplay=stack
DATASKIN=NONE OUTLINE OUTLINEATTRS=(color=black THICKNESS=1) FILL
;
text x=visit y=pos text=N_Percentage / group=drug TEXTATTRS=(Color=black Family="Arial" Size=6 Weight=bold);
run;
Bart
Thanks, it worked
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.