楼主: 若水烟寒
5883 5

[问答] proc sql中有没有汇总中位数的函数呀? [推广有奖]

  • 3关注
  • 9粉丝

博士生

8%

还不是VIP/贵宾

-

威望
0
论坛币
1431 个
通用积分
33.2663
学术水平
14 点
热心指数
18 点
信用等级
12 点
经验
2716 点
帖子
183
精华
0
在线时间
175 小时
注册时间
2011-5-11
最后登录
2023-8-10

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问proc sql中有没有汇总中位数的函数呢?……貌似木有呀……TT,谢谢~
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:proc sql 有没有 sql ROC 中位数 sql 中位数

沙发
yongyitian 发表于 2012-12-18 01:33:54 |只看作者 |坛友微信交流群
The MEDIAN() function is a new function available in V9 and is
documented in "What's New in Base SAS 9 System and Language Features."

The syntax for using this function is shown as:

  MEDIAN(value1<,value2,...>);

When this function is used in PROC SQL, it can only be used to return
the median value for the current row.


The message is from: Usage Note 12133: Limitation of the MEDIAN() function when used in PROC SQL[url]http://support.sas.com/kb/12/133.html[/url]

使用道具

藤椅
jingju11 发表于 2012-12-18 08:28:52 |只看作者 |坛友微信交流群
I wrote a function-like macro %getMedian for that just for fun. You can read here_is_link.
jingju
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
hopewell + 1 + 1 + 1 我很赞同

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

板凳
若水烟寒 发表于 2012-12-18 10:26:39 |只看作者 |坛友微信交流群
jingju11 发表于 2012-12-18 08:28
I wrote a function-like macro %getMedian for that just for fun. You can read here_is_link.
jingju
Thank you very much!^^

使用道具

报纸
若水烟寒 发表于 2012-12-18 10:29:58 |只看作者 |坛友微信交流群
jingju11 发表于 2012-12-18 08:28
I wrote a function-like macro %getMedian for that just for fun. You can read here_is_link.
jingju
Actually, I found another way to solve this problem from the sashelp doc...

data grade;
   input Name $ 1-8 Gender $ 11 Status $13 Year $ 15-16
         Section $ 18 Score 20-21 FinalGrade 23-24;
   datalines;
Abbott    F 2 97 A 90 87
Branford  M 1 98 A 92 97
Crandell  M 2 98 B 81 71
Dennison  M 1 97 A 85 72
Edgar     F 1 98 B 89 80
Faust     M 1 97 B 78 73
Greeley   F 2 97 A 82 91
Hart      F 1 98 B 84 80
Isley     M 2 97 A 88 86
Jasper    M 1 97 B 91 93
;

proc means data=Grade noprint descend;

     class Status Year;

     var Score FinalGrade;

     output out=Sumdata (where=(status='1' or _type_=0))
          mean= median(finalgrade)=MedianGrade;
run;

  proc print data=Sumdata;
   title 'Exam and Course Grades for Undergraduates Only';
   title2 'and for All Students';
run;

使用道具

地板
jingju11 发表于 2012-12-18 10:57:17 |只看作者 |坛友微信交流群
thanks, glad to know. yours are better mine. jingju

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 13:42