我想创建一个年度死亡人数的条形图(基于性别)。我想在x轴上绘制性别和年份,并在Y轴上计数。您能帮忙修改以下代码吗?
TITLE 'DEATH GRAPH BY GENDER';
PROC SGPLOT DATA = DREPORT;
VBAR deathcount / GROUP = gender GROUPDISPLAY = CLUSTER;
RUN;
我无法在Y轴上输入死亡年份。请框架代码。
答案 0 :(得分:1)
VBAR
变量是在水平轴上显示的中点值。
您可能希望将deathcount
作为response
考虑以下示例:
data have_raw;
do id = 1 to 1000;
gender = substr('MF',1 + 2 * ranuni(123),1);
year = 2019 - floor (30 * ranuni(123));
output;
end;
run;
proc sql;
create table have as
select year, gender, count(*) as deathcount
from have_raw
group by year, gender
;
proc sgplot data=have;
vbar gender
/ response=deathcount
group=year
groupdisplay=cluster
;
run;