SAS Chapter 13 Combining Data Sets

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Moxleyv
M
Moxleyv
Community Contributor
Quizzes Created: 38 | Total Attempts: 21,748
| Attempts: 712
SettingsSettings
Please wait...
  • 1/10 Questions

    Which program will combine Brothers.One and Brothers.Two to produce Brothers.Three?

    • Data brothers.three;    set brothers.one;    set brothers.two; run;
    • Data brothers.three;    set brothers.one brothers.two; run;
    • Data brothers.three;    set brothers.one brothers.two;    by varx; run;
    • Data brothers.three;    merge brothers.one brothers.two;    by varx; run;
Please wait...
SAS Chapter 13 Combining Data Sets - Quiz
About This Quiz

This quiz focuses on SAS data management techniques, specifically on combining and merging datasets. It assesses skills in creating new datasets from existing ones, handling variables during merging, and understanding the outcomes of various data manipulation methods in SAS.


Quiz Preview

  • 2. 

    Which program will combine Actors.Props1 and Actors.Props2 to produce Actors.Props3?

    • Data actors.props3;    set actors.props1;    set actors.props2; run;

    • Data actors.props3;    set actors.props1 actors.props2; run;

    • Data actors.props3;    set actors.props1 actors.props2;    by actor run;

    • Data actors.props3;    merge actors.props1 actors.props2;    by actor run;

    Correct Answer
    A. Data actors.props3;    set actors.props1 actors.props2;    by actor run;
    Explanation
    This is a case of interleaving, which requires a list of data set names in the SET statement and one or more BY variables in the BY statement. Notice that observations in each BY statement and one or more BY group are read sequentially, in the order in which the data sets and BY variables are listed. The new data set contains all the variables from all the input data sets, as well as the total number of records from all input data sets.

    Rate this question:

  • 3. 

    If you submit the following program, which new data set is created?

    • None of the above

    Correct Answer
    A.
    Explanation
    Concatenating the observations from one data set to another data set. The new data set contains the total number of records from all input data sets, so b is incorrect. All the variables from all the input data sets appear in the new data set, so c is incorrect.

    Rate this question:

  • 4. 

    If you concatenate the data sets below in the order shown, what is the value of Sale in observation 2 of the new data set?

    • Missing

    • $30,000

    • $40,000

    • You cannot concatenate these data sets.

    Correct Answer
    A. Missing
    Explanation
    The concatenated data sets are read sequentially, in the order in which they are listed in the SET statement. The second observation in Sales.Reps does not contain a value for Sale, so a missing value appears for this variable. (Note that if you merge the data sets, the value of Sale for the second observation is $30,000.)

    Rate this question:

  • 5. 

    What happens if you merge the following data sets by the variable SSN?

    • The values of Age in the 1st data set overwrite the values of Age in the 2nd data set.

    • The values of Age in the 2nd data set overwrite the values of Age in the 1st data set.

    • The DATA step fails to because the two data sets contain same-named variables that have different values.

    • The values of Age in the 2nd data set are set to missing.

    Correct Answer
    A. The values of Age in the 2nd data set overwrite the values of Age in the 1st data set.
    Explanation
    If you have variables with the same name in more than one input data set, values of the same-named variable in the first data set in which it appears are overwritten by values of the same-named variable in the first data set in which it appears are overwritten by values of the same-named variable in subsequent data sets.

    Rate this question:

  • 6. 

    Suppose you merge data sets Health.Set1 and Health.Set2 below: Which output does the following program create? data work.merged;    merge health.set1(in=in1) health.set2(in=in2);    by id;    if in1 and in2; run; proc print data=work.merged; run;

    • None of the above

    Correct Answer
    A.
    Explanation
    The DATA step uses the IN= data set option and the subsetting IF statement to exclude unmatched observations from the output data set. So a and b, which contain unmatched observations, are incorrect.

    Rate this question:

  • 7. 

    The data sets Ensemble.Spring and Ensemble.Summer both contain a variable named Blue.  How do you prevent the values of the variable Blue from being overwritten when you merge the two data sets?

    • Data ensemble.merged;    merge ensemble.spring(in=blue)          ensemble.summer;    by fabric; run;

    • Data ensemble.merged;    merge ensemble.spring(out=blue)          ensemble.summer;    by fabric; run;

    • Data ensemble.merged;    merge ensemble.spring(blue=navy)          ensemble.summer;    by fabric; run;

    • Data ensemble.merged;    merge ensemble.spring(rename=(blue=navy))          ensemble.summer;    by fabric; run;

    Correct Answer
    A. Data ensemble.merged;    merge ensemble.spring(rename=(blue=navy))          ensemble.summer;    by fabric; run;
    Explanation
    Match-merging overwrites same-named variables in the first data set with same-named variables in subsequent data sets. To prevent overwriting, rename variables by using the RENAME= data set option in the MERGE statement.

    Rate this question:

  • 8. 

    What happens if you submit the following program to merge Blood.Donors1 and Blood.Donors2, shown below?

    • The Merged data set contains some missing values because not all observations have matching observations in the other data set.

    • The Merged data set contains eight observations

    • The DATA step produces errors.

    • Values for Units in Blood.Donors2 overwrite values of Units in Blood.Donors1.

    Correct Answer
    A. The DATA step produces errors.
    Explanation
    The two input data sets are not sorted by values of the BY variable, so the DATA step produces errors and stops processing.

    Rate this question:

  • 9. 

    If you merge Company.Staff1 and Company.Staff2 below by ID, how many observations does the new data set contain?  

    • 4

    • 5

    • 6

    • 9

    Correct Answer
    A. 6
    Explanation
    In this example the new data set contains one observation for each unique value of ID. The merged data set is shown below.

    Rate this question:

  • 10. 

    If you merge data sets Sales.Reps, Sales.Close, and Sales.Bonus by ID, what is the value of Bonus in the third observation in the new data set?

    • $4,000

    • $3,000

    • Missing

    • Can't tell from the information given

    Correct Answer
    A. $4,000
    Explanation
    In the new data set, the third observation is the second observation for ID number 2(Kelly Windsor). THe value for Bonus is retained from the previous statement because the BY variable didn't change. The new data set is shown below.

    Rate this question:

Quiz Review Timeline (Updated): Mar 22, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 04, 2013
    Quiz Created by
    Moxleyv

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.