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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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