nerdexam
SAS_Institute

A00-240 · Question #48

This question will ask you to provide a segment of missing code. The following code is used to create missing value indicator variables for input variables, fred1 to fred7. `` data work.train_mi; set

The correct answer is B. do i=1 to dim(mi); mi{i}=(x{i}=.); end;. Option B is correct because fred1–fred7 are numeric variables, and in SAS, numeric missing values are represented by a period (.), not a blank. The Boolean expression (x{i}=.) elegantly evaluates to 1 when the value is missing and 0 otherwise, and dim(mi) dynamically returns the

Regression Models

Question

This question will ask you to provide a segment of missing code. The following code is used to create missing value indicator variables for input variables, fred1 to fred7.
data work.train_mi;
 set work.train;
 array mi{*} MI_fred1-MI_fred7;
 array x{*} fred1-fred7;
 <insert code here>
run;
Which segment of code would complete the task?

Options

  • Ado i=1 to dim(mi); mi{i}=(x{i}=' '); end;
  • Bdo i=1 to dim(mi); mi{i}=(x{i}=.); end;
  • Cdo i=1 to 7; if missing(array(x{))) then array(mi{})=1; end;
  • Ddo i=1 to 7; array(mi)=missing(array(x)); end;

How the community answered

(32 responses)
  • A
    6% (2)
  • B
    88% (28)
  • C
    3% (1)
  • D
    3% (1)

Explanation

Option B is correct because fred1fred7 are numeric variables, and in SAS, numeric missing values are represented by a period (.), not a blank. The Boolean expression (x{i}=.) elegantly evaluates to 1 when the value is missing and 0 otherwise, and dim(mi) dynamically returns the array size - making the loop both accurate and flexible.

Option A is wrong because ' ' (blank) is the missing value check for character variables. Comparing a numeric variable to a blank causes a type mismatch - SAS would not correctly identify missing numerics this way.

Option C is wrong because array(x{*}) and array(mi{*}) are not valid SAS syntax. Arrays are referenced using subscript notation like x{i}, not called as functions. The parentheses also have a syntax error (mismatched )).

Option D is wrong for the same reason - array(mi) and array(x) are invalid syntax. SAS does not treat array references as function calls.

Memory tip: In SAS, think "numeric = dot, character = space" - a number line has dots on it, while character strings are surrounded by spaces. When you see numeric variables, always reach for . to check for missing values.

Topics

#missing value indicators#array processing#data preparation#SAS syntax

Community Discussion

No community discussion yet for this question.

Full A00-240 Practice