Discussion:
PROC SQL and round-function
(too old to reply)
Karlsen, Terje
2004-01-16 16:58:03 UTC
Permalink
Hi!

I am using PROC SQL to round numbers in a data view, but I have trouble rounding the numbers.

proc sql noprint;
create view wk1.tmpnrnar as (
select lm0.nrnar, lm0.status as s, lm0.heldel as h, lm0.kjonn as k,
antjobb as antjobb, round(avatim,2) as avatim from snaar.lm&aarg. lm0
where nrnar in ("23152") and &var1. ne .);

I thought round(avatim,2) would give me avatim with 2 decimals, but I only get the number rounded to nearest integer.
What am I doing wrong? Isn't PROC SQL able to round to nearest decimal level?

Regards,
Terje Karlsen
Statistics Norway
Droogendyk, Harry
2004-01-16 17:12:07 UTC
Permalink
Terje:

You're rounding to the nearest 2. Specify round(var,.01) and you'll be much
happier.

From OnlineDocs:

The ROUND function returns a value rounded to the nearest round-off unit. If
round-off-unit is not provided, a default value of 1 is used and argument is
rounded to the nearest integer.


-----Original Message-----
From: Karlsen, Terje [mailto:***@SSB.NO]
Sent: January 16, 2004 11:58 AM
To: SAS-***@LISTSERV.UGA.EDU
Subject: PROC SQL and round-function


Hi!

I am using PROC SQL to round numbers in a data view, but I have trouble
rounding the numbers.

proc sql noprint;
create view wk1.tmpnrnar as (
select lm0.nrnar, lm0.status as s, lm0.heldel as h,
lm0.kjonn as k,
antjobb as antjobb, round(avatim,2) as avatim from
snaar.lm&aarg. lm0
where nrnar in ("23152") and &var1. ne .);

I thought round(avatim,2) would give me avatim with 2 decimals, but I only
get the number rounded to nearest integer.
What am I doing wrong? Isn't PROC SQL able to round to nearest decimal
level?

Regards,
Terje Karlsen
Statistics Norway

Continue reading on narkive:
Loading...