Saturday, January 12, 2013

SAS: Unwanted blank in PUT output

Check this out!  When using the PUT statement, if a variable is followed by a literal, you always get a blank between the two, but not so when a literal is followed by a variable. In the former case, if you don't want that blank there, you must use the column modifier +(-1) to "back up" one space.  Hardly what I would call intuitive!

Here's some source code:

    data _null_;
    a = 123;
    b = -123;
    put "[" a "]";
    put "[" b "]";
    put "[" a +(-1) "]";
    put "[" b +(-1) "]";
    run;


And here's the output:

    [123 ]
    [-123 ]
    [123]
    [-123]




No comments:

Post a Comment