SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Quiz: Creating Multiple Observations from a Single Record

Select the best answer for each question and click Score My Quiz.

  1. The double trailing at sign (@@) ...

     a.   enables the next INPUT statement to read from the current record across multiple iterations of the DATA step.
     b.   must be the last item specified in the INPUT statement.
     c.   is released when the input pointer moves past the end of the record.
     d.   all of the above

  2. A record held by an @ is automatically released when

     a.   the input pointer moves past the end of the record.
     b.   the next iteration of the DATA step begins.
     c.   another INPUT statement with an @ executes.
     d.   another value is read from the observation.

  3. Which SAS program correctly creates a separate observation for each block of data?

    1---+----10---+----20---+----30---+----40---+
    1001 apple 1002 banana 1003 cherry
    1004 guava 1005 kiwi 1006 papaya
    1007 pineapple 1008 raspberry 1009 strawberry

     a.  
    data perm.produce;
       infile fruit;
       input ItemNumber $4. Variety : $10.;
    run; 
     
     b.  
    data perm.produce;
       infile fruit;
       input ItemNumber $4. Variety : $10. @;
    run;
     
     c.  
    data perm.produce;
       infile fruit;
       input ItemNumber $4. Variety : $10. @@;
    run; 
     
     d.  
    data perm.produce;
       infile fruit @@;
       input ItemNumber $4. Variety : $10.;
    run; 

  4. Which SAS program segment reads the values for ID and holds the record for each value of Quantity,so that three observations are created for each record?

    1---+----10---+----20---+----30
    2101 21,208 19,047 22,890
    2102 18,775 20,214 22,654
    2103 19,763 22,927 21,862

     a.  
    data perm.sales;
       infile unitsold;
       input ID 4. @@;
       .
       .
       .
       input Quantity comma6. @;
     
     b.  
    data perm.sales;
       infile unitsold;
       input ID 4. @@;
       .
       .
       .
       input Quantity comma6.;
     
     c.  
    data perm.sales;
       infile unitsold;
       input ID 4. @;
       .
       .
       .
       input Quantity comma6.;
     
     d.  
    data perm.sales;
       infile unitsold;
       input ID 4. @;
       .
       .
       .
       input Quantity comma6. @;

  5. Which SAS statement repetitively executes several statements when the value of an index-variable named count ranges from 1 to 50, incremented by 5?

     a.  
    do count=1 to 50 by 5;
     b.  
    do while count=1 to 50 by 5;
     c.  
    do count=1 to 50 + 5;
     d.  
    do while (count=1 to 50 + 5); 

  6. Which choice below writes an observation to the data set after each value for Activity has been read?

     a.  
    do choice=1 to 3;
       input activity : $10. @;
       output;
    end;
    run;
     
     b.  
    do choice=1 to 3;
       input activity : $10. @;
    end;
    output;
    run;
     
     c.  
    do choice=1 to 3;
       input activity : $10. @;
    end;
    run;
     
     d.   a and b

  7. Which SAS statement repetitively executes several statements while the value of Cholesterol is greater than 200?

     a.  
    do cholesterol > 200;
     b.  
    do cholesterol gt 200;                    
     c.  
    do while (cholesterol > 200); 
     d.  
    do while cholesterol > 200;

  8. Which choice below is an example of a sum statement?

     a.  
    totalpay=1;
     b.  
    totalpay+1;                    
     c.  
    totalpay*1;
     d.  
    totalpay by 1;

  9. Which program creates a counter variable named Month that is incremented by 1 each time the loop executes?

     a.  
    data perm.topstores;
       infile sales98 missover;
       input StoreNumber 4. Sales comma12. @;
       do while (Sales gt 75000);
          month + 1;
          output;
          input Sales comma12. @;
       end;
    run;
     
     b.  
    data perm.topstores;
       infile sales98 missover;
       input StoreNumber 4. Sales comma12. @;
       do while (Sales gt 75000);
          Month=0;
          month + 1;
          output;
          input Sales comma12. @;
       end;
    run;
     
     c.  
    data perm.topstores;
       infile sales98 missover;
       input StoreNumber 4. Sales comma12. Month 2. @;
       do while (Sales gt 75000);
          month + 1;
          input Sales comma12. @;
       end;
       output;
    run;
     
     d.  
    data perm.topstores;
       infile sales98 missover;
       input StoreNumber 4. Sales comma12. @;
       Month=0;
       do while (Sales gt 75000);
          month + 1;
          output;
          input Sales comma12. @;
       end;
    run;

  10. How many observations are produced by this external file?

    1---+----10---+----20---+----30---+----40
    01 CHOCOLATE VANILLA RASPBERRY
    02 VANILLA PEACH
    03 CHOCOLATE
    04 RASPBERRY PEACH CHOCOLATE
    05 STRAWBERRY VANILLA CHOCOLATE
    data perm.choices;
       infile icecream missover;
       input ID 2. Flavor : $10. @;
       do while (flavor ne ' ');
          output;
          input Flavor : $10. @;
        end;
    run; 

     a.   3
     b.   5
     c.   12
     d.   15



back||next

Terms of Use & Legal Information | Privacy Statement