Perhaps the simplest solution: stop rounding your data. Instead, just apply a format for printing purposes:
format mean 8.3;
Then a printing procedure should include the negative sign in the report.
Thanks astounding, but I need to round my data as it is a requirement from client.. when I apply format just truncation of data happens to decimals but not rounding.. thanks for input
The discussion has centered around the SAS code, but not on the form of the data being provided to the client. If you are providing a text file, you can easily apply the format to unrounded data. Here's a test program, for example, to illustrate:
data _null_;
pos = 0.0001345;
neg = -0.0001345;
put pos 8.3 ',' neg 8.3;
run;
If you are exporting a SAS data set to a .csv file, you can take the generated SAS code (available in the log), and change it slightly by adding your own formats to the PUT statement.
As others have said, the format rounds and keeps the sign.
data HAVE ;
X= +0.0001345; output;
X= -0.0001345; output;
X= +0.0005345; output;
X= -0.0005345; output;
X= +5345.1234; output;
X= -5345.1234; output;
X= +5345.1236; output;
X= -5345.1236; output;
run;
data WANT;
set HAVE;
Y=put(X,10.3);
putlog Y=;
run;
Y=0.000
Y=-0.000
Y=0.001
Y=-0.001
Y=5345.123
Y=-5345.123
Y=5345.124
Y=-5345.124
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.