SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Quiz: Processing Variables with Arrays

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

  1. Which statement is false regarding an ARRAY statement?

     a.   It is an executable statement.
     b.   It can be used to create variables.
     c.   It must contain either all numeric or all character elements.
     d.   It must be used to define an array before the array name can be referenced.

  2. What belongs within the parentheses of this ARRAY statement?
    array contrib( ) qtr1-qtr4;

     a.   qtr
     b.   qtr*
     c.   1-4
     d.   4

  3. For the program below, select an iterative DO statement to process all elements in the CONTRIB array.
    data work.contrib;
       array contrib(4) qtr1-qtr4;
          ...
          contrib(i)=contrib(i)*1.25;
       end;
    run;

     a.   do i=4;
     b.   do i=1 to 4;
     c.   do until i=4;
     d.   do while i le 4;

  4. What is the value of the index variable that references Jul in the statements below?
    array qua(4) jan apr jul oct;
    do i=1 to 4;
    	yeargoal=qua(i)*1.2;
    end;

     a.   1
     b.   2
     c.   3
     d.   4

  5. Which DO statement would not process all the elements in the FACTORS array shown below?
    array factors{*} age height weight bloodpr;

     a.   do i=1 to dim(factors);
     b.   do i=1 to dim(*);
     c.   do i=age to bloodpr;
     d.   do i=1 to 4;

  6. Which statement below is false regarding the use of arrays to create variables?

     a.   The variables are added to the program data vector during compilation of the DATA step.
     b.   You do not need to specify the array elements in the ARRAY statement.
     c.   By default, all character variables are assigned a length of 8.
     d.   Only character variables can be created.

  7. For the first observation, what is the value of DIFF(i) at the end of the second iteration of the DO loop?

     Weight1   Weight2   Weight3 
    192   200   215  
    137   130   125  
    220   210   213  

    array wt{*} weight1-weight10;
    array diff{9};
    do i=1 to 9;
       diff(i)=wt(i+1)-wt(i);
    end;

     a.   15
     b.   10
     c.   8
     d.   -7

  8. Finish the ARRAY statement below to create temporary array elements with initial values of 9000, 9300, 9600, and 9900.
    array goal(4) ... ;

     a.   _temporary_ (9000 9300 9600 9900)
     b.   temporary (9000 9300 9600 9900)
     c.   _temporary_ 9000 9300 9600 9900
     d.   (temporary) 9000 9300 9600 9900

  9. Based on the ARRAY statement below, select the array reference for the array element Q50.
    array ques(3,25) q1-q75;

     a.   ques(q50)
     b.   ques(1,50)
     c.   ques(2,25)
     d.   ques(3,0)

  10. Select the ARRAY statement that defines the array in the following program.
    data rainwear.coat;
       input category high1-high3 / low1-low3;
       ...
       do i=1 to 2;
          do j=1 to 3;
             compare(i,j)=round(compare(i,j)*1.12);
          end;
       end;
    run;

     a.   array compare(1,6) high1-high3 low1-low3;
     b.   array compare(2,3) high1-high3 low1-low3;
     c.   array compare(3,2) high1-high3 low1-low3;
     d.   array compare(3,3) high1-high3 low1-low3;



back||next

Terms of Use & Legal Information | Privacy Statement