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
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.