Site hosted by Angelfire.com: Build your free website today!



 

SAS(r) Software Tips
Finding The True Length Of A Character Variable
The LENGTH function returns the number of characters in a field up to the last non-blank. When you need to know the actual length of the variable in a datastep the following technique can be used:

Run the following code::

  drop __tmp ;
  __tmp = x ;
  x = repeat('A',199) ;
  y = length(x) ;
  x = __tmp ;

The variable Y will contain the true length of X. This is because when you fill X with 200 non-blank characters, the fill only occurs up to the length of the field.

Contact Don Stanley