BookmarkSubscribeRSS Feed
richard_hu2003
Calcite | Level 5
Given the SAS data sets:
WORK.FIRST WORK.SECOND
Common X Common Y
------ -- ------ --
A 10 A 1
A 13 A 3
A 14 B 4
B 9 B 2
The following SAS program is submitted:
data WORK.COMBINE;
set WORK.FIRST;
set WORK.SECOND;
run;
What data values are stored in data
set WORK.COMBINE?
A.
Common X Y
------ -- --
A 10 1
A 13 3
B 14 4
B 9 2
B.
Common X Y
------ -- --
A 10 1
A 13 3
A 14 3
B 9 4
B 9 2
C.
Common X Y
------ -- --
A 10 1
A 13 3
A 14 .
B 9 4
B . 2
D.
Common X Y
------ -- --
A 10 1
A 13 1
A 14 1
A 10 3
A 13 3
A 14 3
B 9 4
B 9 2
Answer:(A)

I don't understand that the third row starts with "B" instead of "A" in answer (A). Why? Can someone help? Thanks. Message was edited by: richard_hu2003
2 REPLIES 2
NickR
Quartz | Level 8
When multiple SET statements are used, number of observations in the new data set is the number of observations in the smallest original data set. If the data sets contain common variables, the values that are read in from the last data set replace those read in from earlier ones.

During the third iteration, when the record is read using SET statement from FIRST dataset, the value of 'Common' in PDV is A. However, when the second SET statement is executed, the value of 'Common' (A) in PDV is replaced by 'B' from SECOND dataset.
richard_hu2003
Calcite | Level 5
Very detailed explanation. Thanks, Nick!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1819 views
  • 0 likes
  • 2 in conversation