楼主: dream9876
4002 2

[问答] 【求助】如何能实现按照变量score百分位数分组并统计变量a的频数和百分比 [推广有奖]

  • 1关注
  • 0粉丝

大专生

91%

还不是VIP/贵宾

-

威望
0
论坛币
2741 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
2681 点
帖子
29
精华
0
在线时间
93 小时
注册时间
2014-10-25
最后登录
2018-9-25

楼主
dream9876 发表于 2015-3-28 10:40:01 |AI写论文
15论坛币
各位大神,sas小白一枚,有一组score数据,想按照score变量百分位数(即前20%,20-40%,40-60%。。。)统计变量a的频数和百分比,不知道怎么实现呀。能否帮帮忙,不胜感激~~~

a   score
1     1
1     3
1     5
1     2
2     7
2     4
2     3
2     6
2     9

最佳答案

天穹下 查看完整内容

data m; input a x; cards; 1 1 1 3 1 5 1 2 2 7 2 4 2 3 2 6 2 9 ; proc sql; create table m as select *, count(x) as sum from m; quit; data m; set m; length group $10.; pctn=_n_/sum; if pctn
关键词:score core 百分位数 SCOR SCO 不胜感激 百分比 如何 统计

沙发
天穹下 发表于 2015-3-28 10:40:02
data m;
input a x;
cards;
1     1
1     3
1     5
1     2
2     7
2     4
2     3
2     6
2     9
;
proc sql;
create table m as
select *, count(x) as sum
from m;
quit;
data m;
set m;
length group $10.;
pctn=_n_/sum;
if pctn<=0.2 then group='20%';
else if 0.2<pctn<=0.4 then group='20-40%';
else if 0.4<pctn<=0.6 then group='40-60%';
  else if 0.6<pctn<=0.8 then group='60-80%';
   else if 0.8<pctn then group='>80%';
run;
proc tabulate data=m;
class a group;
table group,a*(n pctn);
run;
已有 1 人评分论坛币 收起 理由
admin_kefu + 50 热心帮助其他会员

总评分: 论坛币 + 50   查看全部评分

藤椅
dream9876 发表于 2015-3-29 09:26:42
天穹下 发表于 2015-3-28 10:40
data m;
input a x;
cards;
非常感谢!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-25 14:26