BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Astounding
PROC Star

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.

ettinenivarma
Fluorite | Level 6

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 

Astounding
PROC Star

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.

ChrisNZ
Tourmaline | Level 20

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

 

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 18 replies
  • 6937 views
  • 3 likes
  • 9 in conversation