DATA Step, Macro, Functions and more

Combine two data sets in data step

Reply
Contributor
Posts: 27

Combine two data sets in data step

Given the following SAS data sets ONE and TWO: The following
SAS DATA step is submitted:
data combine;
merge one two;
by common;
run;
Which one of the following represents the data values stored
in data set COMBINE?
ONE
OBS COMMON X
1 A 10
2 A 13
3 A 14
4 B 9
5 C 8
6 C 14
TWO
OBS COMMON Y
1 A 1
2 A 3
3 B 4
4 B 2
5 C 5
(A) OBS COMMON X Y
1 A 10 1
2 A 13 3
3 A 14 3
4 B 9 4
5 B 9 2
6 C 8 5
7 C 14 5
(B) OBS COMMON X Y
1 A 10 1
2 A 13 3
3 B 9 4
4 C 8 5
(C) OBS COMMON X Y
1 A 10 1
2 A 13 3
3 B 14 4
4 B 9 2
5 C 8 5
(D) OBS COMMON X Y
1 A 10 1
2 A 13 1
3 A 14 1
4 A 10 3
5 A 13 3
6 A 14 3
7 B 9 4
8 B 9 2
9 C 8 5
10 C 14 5

Answer is (A). But why not (D)? Thanks.
Super Contributor
Super Contributor
Posts: 365

Re: Combine two data sets in data step

Hello Richard_hu2003,

Yes, the answer is A. It is impossible to be D because with this type of merging the combine dataset should contain only three observations for COMMON='A'. The rules of merging are quite complicated and explained in SAS help and relevant books..

Sincerely,
Contributor
Posts: 27

Re: Combine two data sets in data step

Thank you so much! SPR
Ask a Question
Discussion stats
  • 2 replies
  • 383 views
  • 0 likes
  • 2 in conversation