BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12
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.
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
@ Doc@Duke:

With Proc Means you could also use the option MAXDEC = 2.

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 856 views
  • 0 likes
  • 3 in conversation