Return to Archive

SAS Tip of the Month
February 2008

I had an occasion recently to need negative values to to be displayed with a '()' around the value, rather than the more usual '-' in front of the value. Below is the code that was used to do this and a sample of its use:

    proc format;
        picture negvals
           low-<0='00000.0)' (prefix="(" )
           0-high="00000.0" ;
        run;

    72 data _null_;
    73    do pctchng="50" to 50 by 20;
    74       dispval=put(pctchng,negvals.);
    75       put pctchng= dispval=;
    76    end;
    77 run;
    pctchng=50 dispval=50.0
    pctchng=30 dispval=30.0
    pctchng=10 dispval=10.0
    pctchng=-10 dispval=(10.0)
    pctchng=-30 dispval=(30.0)
    pctchng=-50 dispval=(50.0)
________________________________
Updated February 1, 2008