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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 842 views
  • 0 likes
  • 3 in conversation