Quiz

Select the best answer for each question. After completing the quiz, check your answers using the answer key in the appendix.
  1. According to the data set descriptions below, which of the variables that are listed qualify as BY variables for a DATA step match-merge?
    Variable Type Length
    Variable Type Length
    1. Code and IDnum
    2. Manager and Supervisor
    3. Manager and IDnum
    4. 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 variable Startdate, that 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?
    1. You use a MERGE statement in one DATA step to merge Dataset1, Dataset2, and Dataset3 by Startdate and Instructor.
    2. 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.
    3. You can merge these data sets only with a PROC SQL step.
    4. 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?
    1. 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;
    2. proc sql;
         create table usesql as
            select newsals.empcode allemps.lastname
                   newsals.salsry contrib.amount
               from sasuser.allemps, sasuser.contrib,
                    sasuser.newsals
      quit;
    3. 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. 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 input data set to create the PDV and the descriptor portion of the new data set. Which of the following accurately describes the rest of this process?
    1. Next, SAS sequentially match-merges observations reading them into the PDV, and then writes them 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.
    2. Next, SAS sequentially match-merges observations reading them into the PDV, and then writes them 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.
    3. Next, SAS creates a Cartesian product of all possible combinations of observations, writes them to the PDV, and 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.
    4. Next, SAS creates a Cartesian product of all possible combinations of observations, writes them to the PDV, and 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?
    1. You can use multiple SET statements to combine observations from several SAS data sets.
    2. 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).
    3. You can use multiple SET statements in one DATA step only if the data sets in each SET statement have a common variable.
    4. 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 that was created from the Salary variable of the Sasuser.Empdata data set.
    1. proc sum data=sasuser.emdata noprint;
         output out=sasuser.summary sum=Salarysum;
      run;
    2. proc means data=sasuser.empdata noprint;
         var salary;
         output out=sasuser.summary sum=Salarysum;
      run;
    3. proc sum data=sasuser.empdata noprint;
         var salary;
         output out=sasuser.summary sum=Salarysum;
      run;
    4. 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;
    1. $1000
    2. $3000
    3. The value is missing.
    4. 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?
    data sasuser.percent2(drop=totalrev);
       if _n_=1 then do until(lastobs);
          set sasuser.monthsum2(keep=revcargo) 
              end=lastobs;
          totalrev+revcargo;
       end;
       set sasuser.monthsum2 
           (keep=salemon revcargo);
       PctRev=revcargo/totalrev;
    run;
    Observations
    1. The value is missing.
    2. $350.00
    3. $520.00
    4. $1100.00
  9. Which of the following programs correctly uses an index to combine data from two input data sets?
    1. 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;
    2. 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;
    3. 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;
    4. 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?
    1. 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.
    2. 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.
    3. 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.
    4. 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.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.209.131