From: Mindy on
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




From: data _null_; on
On Jun 3, 11:45 am, 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 expect rounding with regards to calculation of A and/or B in the
"large program". Just becasue you see 4800 doesn't mean that is the
actual value. For example.

306 data _null_;
307 aa=4800;
308 a= 4800.000-2e-7;
309 b=0.5316742081;
310 c=(a-b) /b *100.;
311 put (_all_)(=);
312 format a 8.3;
313 put (_all_)(=hex16.);
314 run;

aa=4800 a=4800.000 b=0.5316742081 c=902708.51068
aa=40B2C00000000000 a=40B2BFFFFFFCA502 b=3FE10379A0FD517F
c=412B8C6905776C31

Use HEX16 format in your large program see if the value of A and B are
actually what you think they are.
From: RolandRB on
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
From: Mindy on
On Jun 3, 11:19 am, "data _null_;" <datan...(a)gmail.com> wrote:
> On Jun 3, 11:45 am,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 expect rounding with regards to calculation of A and/or B in the
> "large program".  Just becasue you see 4800 doesn't mean that is the
> actual value.  For example.
>
> 306  data _null_;
> 307     aa=4800;
> 308     a= 4800.000-2e-7;
> 309     b=0.5316742081;
> 310     c=(a-b) /b *100.;
> 311     put (_all_)(=);
> 312     format a 8.3;
> 313     put (_all_)(=hex16.);
> 314  run;
>
> aa=4800 a=4800.000 b=0.5316742081 c=902708.51068
> aa=40B2C00000000000 a=40B2BFFFFFFCA502 b=3FE10379A0FD517F
> c=412B8C6905776C31
>
> Use HEX16 format in your large program see if the value of A and B are
> actually what you think they are.- Hide quoted text -
>
> - Show quoted text -

Thanks a lot. I will test it tomorrow. __ Mindy
From: Mindy on
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