计算 PROC REPORT 中的偏度 [英] Calculate Skewness in PROC REPORT

查看:21
本文介绍了计算 PROC REPORT 中的偏度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下示例数据,我正在为以下对象创建交叉表:

I have the following sample data with I'm creating a crosstab for:

data have1;
   input username $  betdate : datetime. stake winnings;
   dateOnly = datepart(betdate) ;
   format betdate DATETIME.;
   format dateOnly ddmmyy8.;
   datalines; 
    player1 12NOV2008:12:04:01 90 -90 
    player1 04NOV2008:09:03:44 100 40 
    player2 07NOV2008:14:03:33 120 -120 
    player1 05NOV2008:09:00:00 50 15 
    player1 05NOV2008:09:05:00 30 5 
    player1 05NOV2008:09:00:05 20 10 
    player2 09NOV2008:10:05:10 10 -10 
    player2 15NOV2008:15:05:33 35 -35 
    player1 15NOV2008:15:05:33 35 15 
    player1 15NOV2008:15:05:33 35 15 
run;
PROC PRINT; RUN;

Proc rank data=have1 ties=mean out=ranksout groups=2;
     var    stake;
     ranks  stakeRank;
run;

PROC TABULATE DATA=ranksout NOSEPS;
    VAR stake;
    class stakerank;
    TABLE stakerank, stake*N;
        TABLE stakerank, stake*(N Mean Skewness);
RUN;

我想在 PROC REPORT 的 PROC TABULATE 中复制我正在做的事情,因为我需要为均值差测试和其他一些事情添加 p 值.但是,偏度似乎不是 Proc Report 中的内置函数.我该如何计算?

I want to replicate what I'm doing in PROC TABULATE in PROC REPORT as I need to add p-values for a Difference in Means test and a few other things. However, it seems that Skewness is not a built-in function in Proc Report. How can I calculate this?

PROC REPORT DATA=ranksout NOWINDOWS;
  COLUMN stakerank stake, (n mean);
  DEFINE stakerank / GROUP id 'Rank for Variable Stake' ORDER=INTERNAL;
  DEFINE stake / ANALYSIS '';
  define n/format=8. ;
RUN;

感谢您对此的任何帮助

推荐答案

可以如下进行.

向 rankouts1 表添加额外的中间变量:

Adding an extra intermediate variable to the rankouts1 table:

proc sql;
    create table withCubedDeviationsas
    select *,
    ((stake - (select avg(stake) from ranksout1 where stakeRank = main.stakeRank and  winnerRank = main.winnerRank))/(select std(stake) from ranksout1 where stakeRank = main.stakeRank and  winnerRank = main.winnerRank)) **3 format=8.2 as cubeddeviations
    from ranksout1 main;    
quit;

PROC REPORT DATA=withCubedDeviationsNOWINDOWS out=report;
    COLUMN stakerank winnerrank, ( N stake=avg cubeddeviations skewness);
    DEFINE stakerank / GROUP  ORDER=INTERNAL '';
    DEFINE winnerrank / ACROSS  ORDER=INTERNAL '';
    DEFINE cubeddeviations / analysis 'SumCD' noprint;
    DEFINE N / 'Bettors';
    DEFINE avg / analysis mean 'Avg' format=8.2;
    DEFINE skewness / computed format=8.2 'Skewness';
    COMPUTE skewness;
        _C5_ =  _C4_ * (_C2_ / ((_C2_ -1) * (_C2_ - 2)));
        _C9_ =  _C8_ * (_C6_ / ((_C6_ -1) * (_C6_ - 2)));
    ENDCOMP;
RUN;

为什么他们不直接将偏度添加到 PROC 报告中允许的统计列表中?

Why didn't they just add Skewness to the list of statistics that are allowed in a PROC REPORT?

这篇关于计算 PROC REPORT 中的偏度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆