BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
metallon
Pyrite | Level 9

Hi SAS Experts,

I looked at the round function explanation and read that a ,1 should result in no decimals but my calculation reads 100,0 now and not just 100.

proc sql ;
CREATE TABLE mytable AS
SELECT
            ROUND((SUM(numberA)*100)/SUM(numberB),1) AS percent_ab
      FROM aaaa;
QUIT;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Well it's rounded but you're looking to control the display.

 

proc sql ; 
CREATE TABLE mytable AS
SELECT 
            ROUND((SUM(numberA)*100)/SUM(numberB),1) AS percent_ab format=8.
      FROM aaaa;
QUIT;

View solution in original post

2 REPLIES 2
ballardw
Super User

Not quite sure exactly what you mean by "calculation reads 100,0"

Round is applied AFTER the results of

(SUM(numberA)*100)/SUM(numberB)

 

The FORMAT of the varaible percent_ab could be forcing the appearance of decimals. If the format is something like 5.1 it will force the appearance of 1 decimal, showing a 0 when none are actually present.

Reeza
Super User

Well it's rounded but you're looking to control the display.

 

proc sql ; 
CREATE TABLE mytable AS
SELECT 
            ROUND((SUM(numberA)*100)/SUM(numberB),1) AS percent_ab format=8.
      FROM aaaa;
QUIT;

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!

How to Concatenate Values

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.

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
  • 2 replies
  • 15282 views
  • 3 likes
  • 3 in conversation