12-08-2008 10:32 AM
12-08-2008 11:54 AM
06-13-2012 10:28 AM
I tried ROUND, ROUNDE, and ROUNDZ functions and my results still do not turn out correctly. I welcome any suggestion(s) you may have for me.
06-13-2012 10:58 AM
When I did roundz, I got the answer Cynthia described. (SAS 9.3 on Windows). Maybe you need to show your log.
data testo; orig=0.54999999999999; output; Run;
Data testo; Set testo;
FILE LOG; PUT orig rnd rnde rndz;
16 Data testo; Set testo;
17 rnd= round(orig,0.1);
18 rnde= rounde(orig,0.1);
19 rndz= roundz(orig,0.1);
20 FILE LOG; PUT orig rnd rnde rndz;
0.55 0.6 0.6 0.5
06-13-2012 12:32 PM
Thanks Dr. Muhlbaier. Those functions work on single numbers but not when multiplication/division is involved. Do you happen to know the equivalent SAS syntax/functon for ROUND(+B50/J50,0)) in MS Excel? I assume that the plus(+) sign indicate a positive number and not a ceiling function but I could be wrong. Below is part of my syntax:
or should I use result(i)= round((ceiling(numerator(i)))/(denominator(i))) instead?
I wonder if there is anything missing in my code . . .
PS: I have to convert various Excel pivot tables into SAS datasets and my results differ.
06-13-2012 04:43 PM
AFAIK and from a very quick test in Excel the + doesn't do anything.
I've seen people use it as a shortcut instead of typing equals because then excel treats it as a number/formula, and then the round was possibly introduced later on and then doesn't make sense.
Or apparently and old habit from a Lotus user http://www.excelbanter.com/showthread.php?t=178349
From a quick look at how the function works my guess would be you're looking for
06-18-2012 04:12 PM
Thanks alot Reeza. Regardless of how I write the ROUND function, I find that rounding seems to 'operate' differently in SAS and Excel. For instance 46.54421 is rounded to 47 in Excel and 46 in SAS and 46.4645 is rounded to 46 in Excel and 47 in SAS. I will check the link out.
06-18-2012 04:20 PM
No it doesn't...46.544 rounds to 47 and 46.4645 rounds to 46 as expected in both SAS 9.2 and 9.3
I couldn't find a consistent way to get your results either, so you may want to post the code and the numbers you're trying to replicate.
2119 data _null_;
2120 x= round(46.54421, 1);
2121 y= round(46.4645, 1);
2123 put x y;
06-18-2012 04:50 PM
What are numerator(i) and denominator(i)? And what format is applied to the numbers
I still can't get those numbers you're getting, so there's something missing somewhere:
do i =1 to 5;
proc print data=test;
06-19-2012 02:33 PM
It works fine for me still, rounds to 47 as expected, there's something else in code that's causing this issue, not the round function, provide the full code for the data step.
183 data _null_;
184 x= round(49.23333333/1.0577775751, 1);
186 put x x2;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds