如何在 SAS 中找到组中人员的百分比? [英] How do I find the percentage of people in a group in SAS?

查看:37
本文介绍了如何在 SAS 中找到组中人员的百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DATA test;
INPUT name$ group_no$;
CARDS;
John 1 
Michelle 1
Peter 1 
Kai 2
Peter 2
Liam 2
Claire 2 
Sam 3
Jim 3
run;

我如何找到每个组中的人数百分比.即第 1 组中的 33.3%.第 2 组中的 44.4% 等等......

How do I find the percentage of people within each group. i.e 33.3% in group 1. 44.4% in group 2 etc....

我尝试使用下面的代码,但不足以回答我的问题.我相信我可能不得不使用 SQL 代码;

I tried using the code below but it was not sufficient in answering my question. I believe I may have to use SQL code;

Proc FREQ data = test;
TABLE group_no;
BY group_no;
RUN;

请告诉我如何解决这个问题.

Please let me know how to solve the issue.

推荐答案

proc 表示如数据所示 null 是要走的路.在 SQL 中,您可以按如下所示进行操作.

proc means as shown by data null is the way to go. In SQL you can do as shown below.

 proc sql;
select group_no, 
  count(group_no) *100/(select count(*) from test) as percentage format= 5.2
from test
group by group_no
 ;

这篇关于如何在 SAS 中找到组中人员的百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆