gpt4 book ai didi

sas - 使用 Proc sgplot 的条形图中每个条形的不同标签

转载 作者:行者123 更新时间:2023-12-03 21:43:11 30 4
gpt4 key购买 nike

我正在尝试使用 SAS 中的 Proc sgplot 将每个组的数量添加到 xaxis 上的组标签中。这是我想要的数据和图表。我想在 xaxis(手写部分)上有每个条的样本。非常感激你的帮助!

Data have ;
input type sex $ n n_total percent ;
datalines;
0 F 6 29 20.7
1 F 387 496 78.2
0 M 4 15 26.6
1 M 264 305 86.5
;
Run;

proc sgplot data=have ;
vbarparm category= type response=percent /group=sex groupdisplay=cluster datalabel;
run;
我要创建的图形:
enter image description here

最佳答案

您可以计算显示百分比值和文本 n= 的条形数据标签
例子:

Data have ;
input type sex $ n n_total percent ;
datalines;
0 F 6 29 20.7
1 F 387 496 78.2
0 M 4 15 26.6
1 M 264 305 86.5
;
Run;

data plot;
set have;
barlabel = cats(percent) || ' %N/(n=' || cats(n_total, ')');
run;

proc sgplot data=plot;
vbarparm
category=type
response=percent
/ group=sex
groupdisplay=cluster
datalabel=barlabel datalabelfitpolicy=splitalways splitchar='/'
;
label percent = 'Percent N having some attribute';
run;
enter image description here

关于sas - 使用 Proc sgplot 的条形图中每个条形的不同标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66130414/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com