proc sql, output % to 2 decimal places

Reply
anonymous_user
Posts: 0

proc sql, output % to 2 decimal places

I have this code and my output is displaying 0.000315686 but I need it to read 3.15. I have tried to do this on the code but im not getting the result. Can someone please confirm the issues?

proc sql;

create table work.dtv1 as

select

distinct month_date,

balance_outstanding as balance,

curr_index_val as val,

round(balance/val denominator,0.00001) as dtv

from

  1. gbasel.baseljul14

where optimum_platform = 'Optimum'

and Arrears_lit_stage_code not in ('L4','L5','L6')

order by month_date;

quit;

Super User
Posts: 19,860

Re: proc sql, output % to 2 decimal places

Posted in reply to anonymous_user

That doesn't quite look like correct SAS code with the space in the variable name, I'll assume the editor ate a symbol or something.


round(balance/val denominator,0.00001)*10000 as dtv format=8.2

from

anonymous_user
Posts: 0

Re: proc sql, output % to 2 decimal places

Ove tried running the code but now error with this message?  

85 round(balance/val Denominator,0.00001)*10000 as dtv format=8.2

-----------

22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, ',', -, '.',

/, <, <=, <>, =, >, >=, ?, AND, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE,

LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

Super User
Posts: 19,860

Re: proc sql, output % to 2 decimal places

Posted in reply to anonymous_user

the first argument to the round function isn't valid.

round(balance/val Denominator,0.00001)

val denominator?  Is that two separate variables or a single with a underscore?

As initially indicated your code was not correct to start off with.

Trusted Advisor
Posts: 3,215

Re: proc sql, output % to 2 decimal places

Posted in reply to anonymous_user

same question: https://communities.sas.com/message/222621

---->-- ja karman --<-----
New Contributor
Posts: 2

Re: proc sql, output % to 2 decimal places

Posted in reply to anonymous_user

Hi Brandon,

I think Reeza's and Jaap's comments are on point (including checking for bad variables names and the like). Please consider the nature of the comments and don't just copy and paste. The moral of the story is to know how formats work.

Keep in mind that what SAS stores as data is not the same as what you see on the screen in output. You should use FORMAT to control what you see in output (and other output related things), as suggested by others above. Formats can be changed on the fly; defining a format in a dataset is only for convenience.

I would avoid using the round function. See below for why you may not want to use the round function.

Ask a Question
Discussion stats
  • 5 replies
  • 1481 views
  • 0 likes
  • 4 in conversation