全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3959 2
2007-06-18
<P>急着请教:如何在sas iml 里计算一个向量的%25 quantile? funtion PCTL 可以用,但必须是用逗号隔开的几各数,不能求一个向量的。 请朋友们帮忙!谢谢!</P>
二维码

扫码加我 拉你入群

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

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

全部回复
2010-5-4 23:33:08
在等待答案中。学习学习
二维码

扫码加我 拉你入群

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

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

2012-3-14 14:30:50
PROC IML;
   scores={90,62,66,68,70,72,73,74,78,78,78,79,80,81,82,
           82,82,84,84,85,85,85,85,87,88,89,89,89,89,61};
   PRINT scores;
   quartiles=QUARTILE(scores);
   PRINT quartiles;
/** Start Percentile **/
START percentile(x,pct);
   CALL SORT(x,1);
   count=NROW(x);
   pct=pct/100*(count+1);
   fpct=FLOOR(pct);
   cpct=CEIL(pct);
   IF fpct=cpct THEN percentile=x[pct];
   ELSE percentile=x[fpct]+(pct-fpct)* (x[cpct]-x[fpct]);
/* SAS PCTLDF */
RETURN(percentile);
FINISH;
percentile=PERCENTILE(scores,25);
/** End Percentile **/


CALL SORT(scores,1); /* sorts the scores in ascending order */
count=NROW(scores);  
quantile=scores[CEIL(count*.25)];
PRINT quartiles, "25th Percentile:"
      percentile, "25th Quantile:" quantile;
QUIT;
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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