SAS: Mean, median, max and percentiles by two variables

荒凉一梦 提交于 2019-12-13 09:45:24

问题


I have a dataset structured with 5 columns. Month, User, Num1, Num2, Num3.

I'm trying to calculate, for each Num1 Num2 and Num3, the mean, median, max, 25th and 75th percentile for each permutation of Month and User.

I have tried proc univariate but I can't do it without creating a macro and manual steps for each Month and User permutation.

My ideal output would then look like this, and separate outputs for Num1 Num2 Num3: http://i.imgur.com/YC67LV1.png

Thanks!


回答1:


PROC Means does what you want.

Here is an example with the SASHELP.SHOES example dataset.

ods html;
proc means data=sashelp.shoes mean median max p25 p75;
   class region product;
   var sales inventory returns;
run;
ods html close;



回答2:


Have you tried the PROC MEANS ?

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146729.htm

Or can you give a sample input data so I can try to recreate the result?




回答3:


proc sort data = mydata;
 by month user;
run;

proc univariate data = mydata;
 by month user;
 var num1 num2 num3;
run;

You can probably refine this to get only the exact statistics you want using either ODS SELECT or OUTPUT



来源:https://stackoverflow.com/questions/27707707/sas-mean-median-max-and-percentiles-by-two-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!