全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
6349 5
2012-12-17
请问proc sql中有没有汇总中位数的函数呢?……貌似木有呀……TT,谢谢~
二维码

扫码加我 拉你入群

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

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

全部回复
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]
二维码

扫码加我 拉你入群

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

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

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
二维码

扫码加我 拉你入群

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

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

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;

二维码

扫码加我 拉你入群

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

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

2012-12-18 10:57:17
thanks, glad to know. yours are better mine. jingju
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群