使用多个字段作为密钥的PROC SUMMARY

时间:2014-10-13 13:19:33

标签: sas summary

有没有办法使用PROC SUMMARY复制下面的行为而无需创建虚拟变量UniqueKey

DATA table1;
input record_desc $ record_id $ response;
informat record_desc $4. record_id $1. response best32.;
format record_desc $4. record_id $1. response best32.;
DATALINES;
  A001 1 300
  A001 1 150
  A002 1 200
  A003 1 150
  A003 1 99
  A003 2 250
  A003 2 450
  A003 2 250
  A004 1 900
  A005 1 100
;
RUN;

DATA table2;
  SET table1;
  UniqueKey = record_desc || record_id;
RUN;

PROC SUMMARY data = table2 NWAY MISSING;
  class UniqueKey record_desc record_id;
  var response;
  output out=table3(drop = _FREQ_ _TYPE_) sum=;
RUN;

1 个答案:

答案 0 :(得分:2)

您可以通过record_desc和record_id进行汇总(请参阅下面的类语句),而无需创建两列的串联。是什么让你认为你不能?

PROC SUMMARY data = table1 NWAY MISSING;
  class record_desc record_id;
  var response;
  output out=table4(drop = _FREQ_ _TYPE_) sum=;
RUN;


proc compare 
    base=table3
    compare=table4;
run;