PROTO Procedure

Working with Character Variables

You can use character variables for arguments that require a “char *” value only. The character string that is passed is a null string that is terminated at the current length of the string. The current length of the character string is the minimum of the allocated length of the string and the length of the last value that was stored in the string. The allocated length of the string (by default, 32 bytes) can be specified by using the LENGTH statement. Functions that return “char *” can return a null or zero-delimited string that is copied to the SAS variable. If the current length of the character string is less than the allocated length, the character string is padded with a blank.
In the following example, the allocated length of str is 10, but the current length is 5. When the string is NULL-terminated at the allocated length, "hello " is passed to the function xxx:
length str $ 10;
str = "hello";
call xxx(str);
To avoid the blank padding, use the SAS function TRIM on the parameter within the function call:
length str $ 10;
str = "hello";
call xxx(trim(str));
In this case, the value "hello" is passed to the function xxx.