0

I'm trying to use a alias to create multiple statistics for the same variable in PROC REPORT.

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;

I want to add an extra, computed variable to the report above. What am I doing wrong here? I'm sure it's just a small syntax issue, but I'm having no luck with it!

PROC REPORT DATA=ranksout1 NOWINDOWS;
    COLUMN stakerank stake, (n mean stake=discountedstake);
    DEFINE stakerank / GROUP id 'Rank for Variable Stake' ORDER=INTERNAL;
    DEFINE stake / ANALYSIS '';
    define n/format=8. ;
    define discountedstake / analysis format=8.2;
    compute discountedstake;
        discountedstake = stake * 0.9;
    endcompute;
RUN;

Thanks.

4

1 回答 1

1

我不确定你想做什么,但下面我正在使用:

  • 一个变量有两个统计量:

    • stake标记为 Count 正在使用 N 统计量
    • stakemean标记为 Mean 的 Mean 统计量。
  • 并创建一个计算列 - discountedstake(我正在乘以平均统计量。如果您需要乘以原始值,可以通过在数据集顶部创建一个 datastep 视图来完成。)

例子:

PROC REPORT DATA=ranksout NOWINDOWS;
    COLUMN stakerank stake stake = stakemean discountedstake;
    DEFINE stakerank / GROUP id 'Rank for Variable Stake' ORDER=INTERNAL;
    DEFINE stake / ANALYSIS N 'Count';
     DEFINE stakemean / ANALYSIS MEAN 'Mean';
    DEFINE discountedstake / computed format=8.2;
    COMPUTE discountedstake;
        discountedstake = stakemean * 0.9;
    ENDCOMP;
RUN;

您的代码中的问题之一是stake=discountedstake- 创建别名 discountedstake 并计算 discountedstake。

于 2013-09-13T07:36:31.050 回答