@SASPhile wrote:

How to display decimal places for mean median and std based on the data.

age

20

30

50

if the data say min and max for 20 and 50:

mean=33.333333333

std=15.275252317

median=30

How to display statistics as below:

Mean, median 1 decimal more than data. Standard deviation should be 2 decimal more than data (Data varies for each variable).

mean=33.3

std=15.27

median=30.0

I suggest picking a reasonable value and not attempting to determine how many internal decimals are stored and adjusting from that. Many numbers can only be approximated by the binary coding and often use many more "decimal places" in internal storage than you might expect. Plus what do would you want if most of the values are integers and you have one value like 10.12345678? Do you really need 9 decimal places in that case?

And are displayed values at that precision actually needed? If I am talking about real estate prices will often actually have two decimal places (Unites States and values to the nearest cent). But when the mean price of something is like $266,834.281 does the extra tenth of a cent have any practical use? An argument can be made that for most purposes that anything under $100 is likely not meaningful in practical terms.

You can investigate the properties of a variable to find if the format has specified a typical display range but if you have lots of "best8." type formats that wouldn't help.