Is there a way to change all the numeric variables in a data set to 2 decimals, without defining one by one? They have difference lengths, but I hope they all have max 2 decimals
thanks.
Format _numeric_ 8.2;
The keyword is _numeric_ which applies to all numeric variables. But be careful, dates and ID variables can be numeric as well.
Format _numeric_ 8.2;
The keyword is _numeric_ which applies to all numeric variables. But be careful, dates and ID variables can be numeric as well.
What do you mean they "they have different lengths"? Are you talking about the W in W.D as in 10 and 8 in 10.2, 8.2 etc.?
Sample data with working program to read and format as it is now would be helpful. Plus an example data set of the result you desire.
@Reeza suggested the easy solution just format all the variable with W.2 where W is big enough for all values.
You're still a bit light on the details.
Thank you. I agree with you. I just need to choose a large enough W.
By Change, do you mean just format the output to look like it has 2 decimal places, or change the underlying value to have only two decimal places, then you would need the round() function.
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.
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.