Multiple choice technology programming languages

What is the length of variable a ? data temp; a=substr('joshi anand',1,3); run;

  1. 3

  2. 11

  3. 8

  4. 200

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In SAS, when a character variable is created using a function like SUBSTR(), the variable's length is determined by the length of the source string literal, not the length of the result. SUBSTR('joshi anand',1,3) extracts 'joh' but the variable 'a' gets length 11 (length of 'joshi anand'). This is because SAS determines variable lengths at compilation time from the source expression.