BookmarkSubscribeRSS Feed
teja5959
Obsidian | Level 7

data set has data :

id            var

001     1.6764

002     1.6256

003     1.7399

004     1.6129

005     1.7145

 

I want data this data how to get 

  id             var 

001           1.68

002           1.63

003           1.74

004           1.61

005           1.71

 

2 REPLIES 2
Patrick
Opal | Level 21

You have two options.

1. If you just want to PRINT the data rounded to two decimals then use a format: format var 32.2;

2. If you actually want to round the internal value then use the round() function: var=round(var, .01);

 

With option 1) you maintain the full precision for any calculations, aggregations and comparisons.

For example if your internal value is 1.6764 then with format 32.2 it will print as 1.68 BUT in a condition like var>=1.68 the internal value of 1.6764 will get used and though the condition will resolve to FALSE.

ChrisNZ
Tourmaline | Level 20

There is seldom a good reason to change the data. Unless it is erroneous, always use a format as explained by @Patrick .

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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
  • 2 replies
  • 1113 views
  • 7 likes
  • 3 in conversation