以下是我的数据:
ID VALUE
1 1
2 -1
3 1
4 1
5 1
1 1
2 1
3 -1
4 1
5 -1
...
我怎样才能得到这样的表格:
ID value=1 value=-1
1 2 0
2 1 1
3 1 1
4 2 0
5 1 1
value=1
表示每个ID
1
答案 0 :(得分:1)
data work.indata ;
input ID VALUE;
cards;
1 1
2 -1
3 1
4 1
5 1
1 1
2 1
3 -1
4 1
5 -1
;
run;
/*
proc sort data=work.indata;
by ID;
run;
*/
proc freq noprint data=work.indata;
tables ID * VALUE /out=WORK.COUNTS nopercent ;
run;
proc transpose data=WORK.COUNTS out=work.output (drop=_name_ _label_);
id value;
by id;
var count;
run;