g****c 发帖数: 108 | 1 想把数据格式
A 1
A 2
A 3
A 4
B 1
B 2
B 3
B 4
变成
A B (variable name)
1 1
2 2
3 3
4 4
求一个最简单的SAS code。
多谢。 |
d*******o 发帖数: 493 | 2 data have;
input id $ num;
cards;
A 1
A 2
A 3
A 4
B 1
B 2
B 3
B 4
;
run;
****TWO-STEP TRANSPOSE*********;
proc transpose data=have out=want;
by id;
var num;
run;
proc transpose data=want out=want1(drop=_name_);
by _name_;
id id;
var col:;
run; |
R*********i 发帖数: 7643 | 3 Assuming LZ wants the values in A and B matched:
proc sql;
create table new as
select a.num as A, b.num as B
from have(where=(id='A')) a, have(where=(id='B')) b
where a.num=b.num
order by a.num;
quit; |
g****c 发帖数: 108 | |
g****c 发帖数: 108 | |
y****n 发帖数: 46 | 6 data have;
input id $ num;
cards;
A 1
A 2
A 3
A 4
B 1
B 2
B 3
B 4
;
run;
proc sort data=have;
by num id;
run;
proc transpose data=have out=want(drop=_name_ num);
by num notsorted;
var num;
id id;
run; |