[英]how to calculate percentile in SAS
I want to calculate the 95th percentile of a distribution. 我想计算分布的第95个百分位数。 I think I cannot use
proc means
because I need the value, while the output of proc means
is a table. 我认为我不能使用
proc means
因为我需要值,而proc means
的输出是一个表。 I have to use the percentile to filter the dataset and create another dataset with only the observations greater than the percentile. 我必须使用百分位数过滤数据集并创建仅观察值大于百分位数的另一个数据集。 Clearly I don't want to use the numeric value..because I want to use it in a
macro
. 显然我不想使用数字值。因为我想在
macro
使用它。
Don't put summary statistics into macro variables. 不要将摘要统计信息放入宏变量中。 You risk loss of precision.
您可能会损失精度。 This is based on your cryptic description of the problem.
这是基于您对问题的神秘描述。
proc means...
output out=pct95 pct95=
run;
data subset;
if _n_ eq 1 then set pct95;
set data;
if value < pct95;
run;
You can suppress proc means from outputting your results in a new tab using the noprint option. 您可以使用noprint选项禁止proc means将结果输出到新选项卡中。 Try this:
尝试这个:
proc means data = your_data noprint;
var variable_name;
output out = your_data2 p95= / autoname;
run;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.