Chapter Quiz

Select the best answer for each question. Check your answers using the answer key in the appendix.
  1. When you write a DATA step to create one observation per detail record, what do you need to do?
    1. Distinguish between header and detail records.
    2. Keep the header record as a part of each observation until the next header record is encountered.
    3. Hold the current value of each record type so that the other values in the record can be read.
    4. All of the above.
  2. Which SAS statement reads the value for code (in the first field), and then holds the value until an INPUT statement reads the remaining value in each observation in the same iteration of the DATA step?
    Reading Input Values
    1. input code $2. @;
    2. input code $2. @@;
    3. retain code;
    4. none of the above
  3. Which SAS statement checks for the condition that Record equals C and executes a single statement to read the values for Amount?
    1. if record=c then input @3 Amount comma7.;
    2. if record='C' then input @3 Amount comma7.;
    3. if record='C' then do input @3 Amount comma7.;
    4. if record=C then do input @3 Amount comma7.;
  4. After the value for code is read in the sixth iteration, which illustration of the program data vector is correct?
    Reading Input Values
    data perm.produce (drop=code);  
       infile orders; 
       retain Vegetable; 
       input code $1. @; 
       if code='H' then input @3 vegetable $6.; 
       if code='P'; 
       input @3 Variety : $10. @15 Supplier : $15.; 
    run; 
    proc print data=perm.produce; 
    run;
    1. Program Data Vector
    2. Program Data Vector
    3. Program Data Vector
    4. Program Data Vector
  5. What happens when the fourth iteration of the DATA step is complete?
    Iteration in a DATA Step
    data perm.orders (drop=type);  
       infile produce;  
       retain Fruit;  
       input type $1. @;  
       if type='F' then input @3 fruit $7.;  
       if type='V';  
       input @3 Variety : $16. @20 Price comma5.;  
    run;
    1. All of the values in the program data vector are written to the data set as the third observation.
    2. All of the values in the program data vector are written to the data set as the fourth observation.
    3. The values for Fruit, Variety, and Price are written to the data set as the third observation.
    4. The values for Fruit, Variety, and Price are written to the data set as the fourth observation.
  6. Which SAS statement indicates that several other statements should be executed when Record has a value of A?
    Processing a Record
    1. if record='A' then do;
    2. if record=A then do;
    3. if record='A' then;
    4. if record=A then;
  7. Which is true for the following statements (X indicates a header record)?
    if code='X' then do; 
       if _n_ > 1 then output; 
       Total=0; 
       input Name $ 3-20; 
    end;
    1. _N_ equals the number of times the DATA step has begun to execute.
    2. When code='X' and _n_ > 1 are true, an OUTPUT statement is executed.
    3. Each header record causes an observation to be written to the data set.
    4. Both a and b.
  8. What happens when the condition Type='P' is false?
    if type='P' then input @3 ID $5. @9 Address $20.;  
    else if type='V' then input @3 Charge 6.;
    1. The values for ID and Address are read.
    2. The values for Charge are read.
    3. Type is assigned the value of V.
    4. The ELSE statement is executed.
  9. What happens when Last has a value other than zero?
    data perm.househld (drop=code);  
       infile citydata end=last;  
       retain Address;  
       input type $1. @;  
       if code='A' then do;  
          if _n_ > 1 then output;  
          Total=0; 
          input address $ 3-17;  
       end;  
       else if code='N' then total+1;  
       if last then output;  
    run;
    1. Last has a value of 1.
    2. The OUTPUT statement writes the last observation to the data set.
    3. The current value of last is written to the DATA set.
    4. Both a and b.
  10. Based on the values in the program data vector, what happens next?
    Program Data Vector
    data work.supplies (drop=type amount); 
       infile orders end=last; 
       retain Department Extension; 
       input type $1. @; 
       if type='D' then do; 
          if _n_ > 1 then output; 
          Total=0; 
          input @3 department $10. @16 extension $5.; 
       end; 
       else if type='S' then do; 
          input @16 Amount comma5.; 
          total+amount; 
          if last then output; end; 
    run;
    1. All the values in the program data vector are written to the data set as the first observation.
    2. The values for Department, Total, and Extension are written to the data set as the first observation.
    3. The values for Department, Total, and Extension are written to the data set as the fourth observation.
    4. The value of Last changes to 1.
Last updated: January 10, 2018
..................Content has been hidden....................

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