Statistical Analysis System (SAS) Programming Certification Practice Exam

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for the SAS Programming Certification Exam with a variety of questions and detailed explanations. Enhance your SAS skills and increase your confidence. Get ready for success!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which of the following can determine the length of a new variable in SAS?

  1. The length of the variable's first reference in the DATA step.

  2. The assignment statement.

  3. The LENGTH statement.

  4. All of the above.

The correct answer is: All of the above.

In SAS, there are several ways to determine the length of a new variable, making the option suggesting all of the listed methods the correct choice. The LENGTH statement explicitly defines the length of a variable, making it a straightforward way when you want to set a specific length upfront. For example, if you use `LENGTH var_name $ 20;`, this will ensure that the variable `var_name` can hold up to 20 characters. The length of the variable's first reference in the DATA step can also influence the variable's length. When SAS encounters a new variable initially, it determines the length based on the first time it is referenced, either in an assignment or a calculation. For instance, if a variable is defined when assigned a character string of 15 characters, SAS will set the length to accommodate that first reference. Additionally, the assignment statement contributes to determining the variable length, particularly with character variables. When a variable is assigned a character string, SAS adjusts the length of that variable based on the length of the assigned string. If a variable called `new_var` is assigned a value with a length of 10 characters, it gets adjusted to hold up to 10 characters. All these methods (the LENGTH statement, the first