From: Jin Lin on
On Jun 8, 11:59 pm, Mindy <master2005_...(a)yahoo.com> wrote:
> On Jun 5, 12:01 am, RolandRB <rolandbe...(a)hotmail.com> wrote:
>
>
>
>
>
> > On Jun 3, 6:45 pm,Mindy<master2005_...(a)yahoo.com> wrote:
>
> > > Hey, Guys,
>
> > > This question really bothers me:
>
> > > I have a= 4800.000, b=0.5316742081 and c=(a-b) /b *100.
>
> > > If the code runs dependtly , the  c with best. is  c=902708.51071.
>
> > > But when the code is part of a large  program, it gives me the value
> > > of c=902708.51064 unless I play some tricks such as
> > > d =input(put(b, best12.), best12.);
> > > c=(a-d)/d*100, I could get c=902708.51071 as expected.
>
> > > I use "put" to print out the data in the large program with best.
> > > format, and the value of a and b is just as I listed above. So I
> > > think
> > > SAS should use a=4800.000 and b=0.5316742081 when calculate c,
> > > but ...
>
> > > The data of a and b is displayed with format=8.3 in orginal feeding
> > > data set, but I think it should not matter. Anyway, no clue ...
>
> > > Any comments are really appreciated.
>
> > > Thanks a lot,
> > >Mindy
>
> > I am guessing that the value of b has more decimal places and that you
> > are using a format to view it that obscures these extra decimal
> > places. I added "45" to the value of b at the end and I get the same
> > result you did.
>
> > 114  data _null_;
> > 115  a= 4800.000;
> > 116  b=0.531674208145;
> > 117  c=(a-b)/b*100;
> > 118  put c=;
> > 119  run;
>
> > c=902708.51064- Hide quoted text -
>
> > - Show quoted text -
>
> Thanks for considering the question. It did give me some thoughts. I
> will re_check the whole program tomorrow. ___ Mindy- Hide quoted text -
>
> - Show quoted text -

You can try to add a format statement in the proc print . It could be
a rounding issue. Don't use best12 because it is not decimal friendly.
Try specify the number of digit after decimal.