o*****a 发帖数: 229 | 1 I have 2 datasets, one is like
planid level1
100 A
100 B
100 C
the other one is
planid level2
100 D
I want the output to be
planid level1 level2
100 A D
100 B .
100 C .
I have tried different ways, and I can only get
planid level1 level2
100 A D
100 B D
100 C D
or
planid level1 level2
100 A .
100 B .
100 C .
100 . D
But these 2 outputs are not what I want... Does anyone know how to
accomplish this? Thank you very much! |
h******e 发帖数: 1791 | 2 给每个dataset加个变量n,其值为_N_,然后在merge就行了。 |
o*****a 发帖数: 229 | |
k*******a 发帖数: 772 | 4 Here is my solution, maybe too stupid:)
data a;
input planid level1 $;
datalines;
100 A
100 B
100 C
200 D
200 E
200 F
;
data b;
input planid level2 $;
datalines;
100 D
100 Z
200 H
;
data a;
set a;
by planid;
if first.planid then count=0;
count+1;
data b;
set b;
by planid;
if first.planid then count=0;
count+1;
data c;
merge a b;
by planid count;
drop count;
proc print data=c;run; |
R*****g 发帖数: 99 | 5 data ab;
merge a b; *don't add BY statement;
run;
【在 o*****a 的大作中提到】 : I have 2 datasets, one is like : planid level1 : 100 A : 100 B : 100 C : the other one is : planid level2 : 100 D : I want the output to be : planid level1 level2
|