proc sql rounding percentage no decimals

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 133
Accepted Solution

proc sql rounding percentage no decimals

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;


Accepted Solutions
Solution
‎05-04-2016 07:30 AM
Super User
Posts: 19,787

Re: proc sql rounding percentage no decimals

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


All Replies
Super User
Posts: 11,343

Re: proc sql rounding percentage no decimals

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.

Solution
‎05-04-2016 07:30 AM
Super User
Posts: 19,787

Re: proc sql rounding percentage no decimals

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 2926 views
  • 2 likes
  • 3 in conversation