P****l 发帖数: 156 | 1 我又两个data set a b
data A
id distance
1 e
2 g
3 h
data B
nu ran
12 44
11 33
我想要一个dataset 是这个样子的
id distance nu_1 ran_1 nu_2 ran_2
1 e 12 44 11 33
2 g 12 44 11 33
3 h 12 44 11 33
怎么实现?>.< | a***d 发帖数: 336 | 2 I am new to SAS too. If your data is not too big, here is a tedious way:
proc sql;
create table C as
select a.*, b.*
from A, B;
quit;
proc transpose data=C out=C1;
by id distance;
var nu;
run;
proc transpose data=C out=C2;
by id distance;
var ran;
run;
data D;
merge C1 C2;
by id distance;
drop _NAME_
run;
【在 P****l 的大作中提到】 : 我又两个data set a b : data A : id distance : 1 e : 2 g : 3 h : data B : nu ran : 12 44 : 11 33
| j******o 发帖数: 127 | 3 data c;
if _n_=1 then do;
set b (rename=(nu=nu1 ran=ran1) firstobs=1 obs=1);
set b (rename=(nu=nu2 ran=ran2) firstobs=2 obs=2);
end;
set a;
run; | g****8 发帖数: 2828 | | P****l 发帖数: 156 | |
|