Desktop productivity for business analysts and programmers

how to get value 2 places after decimals

Reply
Not applicable
Posts: 0

how to get value 2 places after decimals

I have variable in which I am getting a value four places after decimals.
I want that value to be 2 places after decimals.

for example:
a variable v1=0.1234
but i want the variable value to be only 0.12

Is there any function in sas which I can use to achieve this?
Trusted Advisor
Posts: 2,127

Re: how to get value 2 places after decimals

Posted in reply to deleted_user
The ROUND function may do what you want. CEIL, FLOOR, and INT are also possibilities; check SAS documentaiton for the differences.

If you just want the display to be 2 digits after the decimal, then you can apply a format to the variable.

Some statistical procedures, like PROC MEANS, sometimes give more decimals than desired. The only way to force the format is to output the summary statisticis into a dataset and apply a format for printing.
SAS Super FREQ
Posts: 9,423

Re: how to get value 2 places after decimals

The other approach, depending on the procedure that's producing the number is to alter the table template used for the procedure, as described in this Tech Support FAQ: http://support.sas.com/ctx/samples/index.jsp?sid=285&tab=details

Although the FAQ discusses PROC FREQ, the techniques are translatable to any procedure that has a table template. To determine the name of the table template that you must change, you would have to use ODS TRACE to find the template name for your output object of interest.

cynthia
Not applicable
Posts: 0

Re: how to get value 2 places after decimals

Posted in reply to deleted_user
@ Doc@Duke:

With Proc Means you could also use the option MAXDEC = 2.
Ask a Question
Discussion stats
  • 3 replies
  • 179 views
  • 0 likes
  • 3 in conversation