Multiple choice technology programming languages

x='Hello' y=transwrd(x,'He','HiHiHe') what is the length of y?

  1. 200

  2. 9

  3. 5

  4. 10

Reveal answer Fill a bubble to check yourself
A Correct answer
AI explanation

This is a SAS DATA step gotcha involving TRANWRD (character substring replacement, sometimes mistyped as 'TRANSWRD'). When a new variable like y is created purely from a character function's result without an explicit LENGTH statement, and SAS can't determine the resulting length at compile time, it defaults the variable's length to 200 characters — a well-known SAS behavior for functions like TRANWRD, SCAN, and TRIM. Even though the actual substituted text ('HiHiHello', replacing 'He' with 'HiHiHe' in 'Hello') is only 9 characters, the variable y is allocated length 200 by default. So the 'length of y' (the variable's storage length) is 200, not the length of its current content.