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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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