Space Management for Text Variables
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.
View the .pdf of this paper.
- Csont, W.C. (2008), "When a Period Really is Not a Period and How to Fix It", Proceedings of the 2008 Annual Conference of the Pharmaceutical Industry SAS Users Group, paper CC19.
- Murphy, W.C. (2006), "Squeezing Information out of Data", Proceedings of the Thirty-First Annual SAS® Users Group International Conference, SAS Institute Inc., Cary, NC, paper 028-31.
- Vyverman, K. (2001), "Using Dynamic Data Exchange to Export Your SAS Data to MS Excel", Proceedings of the Twenty-Sixth Annual SAS® Users Group International Conference, SAS Institute Inc., Cary, NC, paper 11.