SAS Chapter 15: Combining Data Horizontally

10 Questions | Total Attempts: 82

SettingsSettingsSettings
SAS Chapter 15: Combining Data Horizontally

Practice for the SAS advance certification exam.


Questions and Answers
  • 1. 
    According to the data set descriptions below, which of the variables listed qualify as BY variables for a DATA step match-merge?
    • A. 

      Code and IDnum

    • B. 

      Manager and Supervisor

    • C. 

      Manager and IDnum

    • D. 

      There are no variables that are common to both of these data sets.

  • 2. 
    Suppose you want to merge Dataset1, Dataset2, and Dataset3. Also suppose that Dataset1 and Dataset2 have the common variableStartdate, Dataset2 and Dataset3 have the common variable Instructor, and that these data sets have no other common variables. How can you use a DATA step to merge these three data sets into one new data set?
    • A. 

      You use a MERGE statement in one DATA step to merge Dataset1, Dataset2, and Dataset3 by Startdate and Instructor.

    • B. 

      You sort Dataset1 and Dataset2 by Startdate and merge them into a temporary data set in a DATA step. Then you sort the temporary data set and Dataset3 by Instructor and merge them into a new data set in a DATA step.

    • C. 

      You can merge these data sets only with a PROC SQL step.

    • D. 

      You cannot merge these three data sets at all because they do not have a common variable.

  • 3. 
    Which of the following programs correctly creates a table with the results of a PROC SQL inner join matched on the values of empcode?
    • A. 

      proc sql; select newsals.empcode allemps.lastname newsals.salary contrib.amount from sasuser.allemps, sasuser.contrib, sasuser.newsals where empcode=allemps.empid and empcode=contrib.empid; quit;

    • B. 

      proc sql; create table usesql as select newsals.empcode allemps.lastname newsals.salsry contrib.amount from sasuser.allemps, sasuser.contrib, sasuser.newsals quit;

    • C. 

      proc sql; create table usesql as; select newsals.empcode, allemps.lastname, newsals.salary, contrib.amount; from sasuser.allemps, sasuser.contrib, sasuser.newsals; where empcode=allemps.empid and empcode=contrib.empid; quit;

    • D. 

      proc sql; create table usesql as select newsals.empcode, allemps.lastname, newsals.salary, contrib.amount from sasuser.allemps, sasuser.contrib, sasuser.newsals where empcode=allemps.empid and empcode=contrib.empid; quit;

  • 4. 
    To process a default DATA step match-merge, SAS first reads the descriptor portion of each data set and sets up the PDV and the descriptor portion of the new data set. Which of the following accurately describes the rest of this process?
    • A. 

      Next, SAS sequentially match-merges observations and writes the new observation to the PDV, then to the new data set. When the BY value changes in all the input data sets, the PDV is initialized to missing. Missing values for variables, as well as missing values that result from unmatched observations, are written to the new data set.

    • B. 

      Next, SAS sequentially match-merges observations and writes the new observation to the PDV, then to the new data set. After each DATA step iteration, the PDV is initialized to missing. Missing values for variables, as well as missing values that result from unmatched observations, are omitted from the new data set.

    • C. 

      Next, SAS creates a Cartesian product of all possible combinations of observations and writes them to the PDV, then to the new data set. Then SAS goes through the new data set and eliminates all observations that do not have matching values of the BY variable.

    • D. 

      Next, SAS creates a Cartesian product of all possible combinations of observations and writes them to the PDV, then to the new data set. The new data set is then ordered by values of the BY variable.

  • 5. 
    Which of the following statements is false about using multiple SET statements in one DATA step?
    • A. 

      You can use multiple SET statements to combine observations from several SAS data sets.

    • B. 

      Processing stops when SAS encounters the end-of-file (EOF) marker on either data set (even if there is more data in the other data set).

    • C. 

      You can use multiple SET statements in one DATA step only if the data sets in each SET statement have a common variable.

    • D. 

      The variables in the PDV are not reinitialized when a second SET statement is executed.

  • 6. 
    Select the program that correctly creates a new data set named Sasuser.Summary that contains one observation with summary data created from the Salary variable of the Sasuser.Empdata data set.
    • A. 

      proc sum data=sasuser.emdata noprint; output out=sasuser.summary sum=Salarysum; run;

    • B. 

      proc means data=sasuser.empdata noprint; var salary; output out=sasuser.summary sum=Salarysum; run;

    • C. 

      proc sum data=sasuser.empdata noprint; var salary; output out=sasuser.summary sum=Salarysum; run;

    • D. 

      proc means data=sasuser.empdata noprint; output=sasuser.summary sum=Salarysum; run;

  • 7. 
    If the value of Cargosum is $1000 at the end of the first iteration of the DATA step shown below, what is the value of Cargosum in the PDV when the DATA step is in its third iteration? data sasuser.percent1; if _n_=1 then set sasuser.summary (keep=cargosum); set sasuser.monthsum (keep=salemon revcargo); PctRev=revcargo/cargosum; run;
    • A. 

      $1000

    • B. 

      $3000

    • C. 

      The value is missing.

    • D. 

      The value cannot be determined without seeing the data that is in Sasuser.Summary.

  • 8. 
    According to the data set shown, what is the value of Totalrev in the PDV at the end of the fourth iteration of the DATA step?
    • A. 

      The value is missing.

    • B. 

      $350.00

    • C. 

      $520.00

    • D. 

      $1100.00

  • 9. 
    Which of the following programs correctly uses an index to combine data from two input data sets?
    • A. 

      data work.profit; set sasuser.sale2000(keep=routeid flightid date rev1st revbusiness revecon revcargo) key=flightdate; set sasuser.dnunder; Profit=sum(rev1st, revbusiness, revecon, revcargo, -expenses); run;

    • B. 

      data work.profit; set sasuser.dnunder; set sasuser.sale2000(keep=routeid flightid date rev1st revbusiness revecon revcargo) key=flightdate; where routeid='0000103'; Profit=sum(rev1st, revbusiness, revecon, revcargo, -expenses); run;

    • C. 

      data work.profit; set sasuser.dnunder; set sasuser.sale2000(keep=routeid flightid date rev1st revbusiness revecon revcargo); key=flightdate; Profit=sum(rev1st, revbusiness, revecon, revcargo, -expenses); run;

    • D. 

      data work.profit; set sasuser.dnunder; set sasuser.sale2000(keep=routeid flightid date rev1st revbusiness revecon revcargo) key=flightdate; Profit=sum(rev1st, revbusiness, revecon, revcargo, -expenses); run;

  • 10. 
    Which of the following statements about the _IORC_ variable is false?
    • A. 

      It is automatically created when you use either a SET statement with the KEY= option or the MODIFY statement with the KEY= option in a DATA step.

    • B. 

      A value of zero for _IORC_ means that the most recent SET statement with the KEY= option (or MODIFY statement with the KEY= option) did not execute successfully.

    • C. 

      A value of zero for _IORC_ means that the most recent SET statement with the KEY= option (or MODIFY statement with the KEY= option) executed successfully.

    • D. 

      You can use the _IORC_ variable to prevent nonmatching data from being included when you use an index to combine data from multiple data sets.

Related Topics
Back to Top Back to top