SAS Chapter 16 Processing Variables With Arrays

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Moxleyv
M
Moxleyv
Community Contributor
Quizzes Created: 38 | Total Attempts: 21,479
Questions: 10 | Attempts: 624

SettingsSettingsSettings
SAS Chapter 16 Processing Variables With Arrays - Quiz

Practice for the SAS base certification exam


Questions and Answers
  • 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.

    Correct Answer
    A. It is an executable statement
    Explanation
    An array statement is not an executable statement; it merely defines an array.

    Rate this question:

  • 2. 

    What belongs within the braces of this ARRAY statement? array contrib{?} qtr1-qtr4;

    • A.

      Quarter

    • B.

      Quarter*

    • C.

      1-4

    • D.

      4

    Correct Answer
    D. 4
    Explanation
    The value in parentheses indicates the number of elements in the array. In the case, there are four elements.

    Rate this question:

  • 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;

    Correct Answer
    B. Do i=1 to 4;
    Explanation
    In the DO statement, you specify the index variable that represents the values of the array elements. Then specify the start and stop positions of the array elements.

    Rate this question:

  • 4. 

    What is the value of the index variable that references Jul in the statements below? array quarters{4} Jan Apr Jul Oct; do i=1 to 4;    yeargoal=quarter{1}*1.2; end;

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      4

    Correct Answer
    C. 3
    Explanation
    The index value represents the positions of the array element. In this case, the third element is Jul.

    Rate this question:

  • 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=1,2,3,4;

    • D.

      Do i=1 to 4;

    Correct Answer
    B. Do i=1 to dim(*)
    Explanation
    To process all the elements in an array, you can either specify the array dimension or use the DIM function with the array name as the argument.

    Rate this question:

  • 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 the 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 eight.

    • D.

      Only character variables can be created.

    Correct Answer
    D. Only character variables can be created.
    Explanation
    Either numeric or character variables can be created by an ARRAY statement.

    Rate this question:

  • 7. 

    For the first observation, what is the value of diff{i} at the end of the second iteration of the DO loop?

    • A.

      15

    • B.

      10

    • C.

      8

    • D.

      -7

    Correct Answer
    A. 15
    Explanation
    At the end of the second iteration, diff{i} resolves as follows:
    diff{2}=wt{2+2};
    diff{2}=215-200

    Rate this question:

  • 8. 

    Finish the ARRAY statement below to create temporary array elements that have 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

    Correct Answer
    A. _temporary_ (9000 9300 9600 9900)
    Explanation
    To create temporary array elements, specify _TEMPORARY_ after the array name and dimension. Specify an initial value for each element, separated by either blanks or commas, and enclose the values in parentheses.

    Rate this question:

  • 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}

    Correct Answer
    C. Ques{2,25}
    Explanation
    This two-dimensional array would consist of three rows of 25 elements. The first row would contain q1 through q25, the second row would start with q26 and end with q50, and the third row would start with q51 and end with q75.

    Rate this question:

  • 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;

    Correct Answer
    B. Array compare{2,3} high1-high3 low1-low3;
    Explanation
    The nested DO loops indicate that the array is named compare and is a two-dimensional array that has two rows and three columns.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 11, 2013
    Quiz Created by
    Moxleyv

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.