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
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.
There is seldom a good reason to change the data. Unless it is erroneous, always use a format as explained by @Patrick .
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.