Space Management for Text Variables

From sasCommunity
Jump to: navigation, search
William C. Murphy
Howard M. Proskin & Associates, Inc.


Spaces in text strings are vitally important. Without spaces between words, text would be completely unreadable and impossible to align. However, too many spaces between the words would leave the text just as difficult to read. The statements and functions of the SAS® system sometimes insert or remove spaces in a surprising way. Fortunately, SAS also provides us with functions such as TRIM and STRIP to remove unwanted spaces. Furthermore with the proper choice of functions and options, excess spaces need not be generated. On the other hand, retaining spaces in variables can be just as much of a problem. For instance, in creating macro variables with the %LET statement, careful consideration must be given to retain spaces before or after the character string. Careful attention must also be paid to text variable created with the concatenation functions. Various functions and statements such as those already mentioned and others, such as PUT and SUBSTR, will be examined to insure the proper maintenance and control of spaces in text strings.

Online materials

View the .pdf of this paper.