BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kmardinian
Quartz | Level 8

Hi, I am trying to round an average to one decimal place without losing the trailing zero if it rounds to a whole number.

 

For example 8.255 --> 8.3

10.01--->10.0 (instead of 10, which my program is currently outputting)

 

data x;

set y;

avg=round(average,0.1);

run;

 

Thank you, any help is much appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
Numeric variables don't contain digits. They only contain values. If you want to print with one position after the decimal point, apply a format. For example, if all your numbers are less than 1000, you could add:

format x 5.1;

Once you do that, you can remove the ROUND function

View solution in original post

6 REPLIES 6
Astounding
PROC Star
Numeric variables don't contain digits. They only contain values. If you want to print with one position after the decimal point, apply a format. For example, if all your numbers are less than 1000, you could add:

format x 5.1;

Once you do that, you can remove the ROUND function
kmardinian
Quartz | Level 8

Thank you, that worked perfectly!

kmardinian
Quartz | Level 8

Is there a way to ensure that this will correctly output to once decimal place in an excel file?

ballardw
Super User

@kmardinian wrote:

Is there a way to ensure that this will correctly output to once decimal place in an excel file?


How are you intending to send data to Excel? Some won't, Proc Export for example, and others basically just set the EXCEL display rule using TAGATTR in one of the report procedures.

kmardinian
Quartz | Level 8

I was going to use a proc report ODS  statement

 

ODS _ALL_ CLOSE;
ods excel file = "&outpath.&file..xlsx"
options ( SHEET_NAME="Report"
AUTOFILTER = "all"
EMBEDDED_TITLES ="yes"
ORIENTATION ="landscape"
frozen_headers='3'
absolute_column_width='8, 10, 16, 12'
) ;

 

proc report data=xx

Astounding
PROC Star
I can't say. I never exported data to Excel.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 9156 views
  • 0 likes
  • 3 in conversation