LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 3 May 2000 18:41:19 -0700
Reply-To:     latuttle <latuttle@EMAIL.MSN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         latuttle <latuttle@EMAIL.MSN.COM>
Subject:      Re: Problem wit fct mean in sas 7 on Unix?

Maybe I am missing something.

Assume for a moment that my_xtot and xtot are exactly equal.

338 my_cond = my_xtot > 6; 339 cond = xtot > 6;

Won't these statements resolve as:

my_cond= (not true, returns 0); cond= (not true, returns 0); thus my_cond and cond will always be zero when the two 'averages' are perfectly equal?

If you run this data step... 349 data test; 350 set mydata; 351 if my_xtot ne xtot; 352 run;

NOTE: There were 38 observations read from the dataset WORK.MYDATA. NOTE: The data set WORK.TEST has 0 observations and 27 variables. NOTE: DATA statement used: real time 0.04 seconds

... you get an empty dataset because the two 'means' are exactly equal.

Laura

<belislep@my-deja.com> wrote in message news:8epu1a$lu3$1@nnrp1.deja.com... > Dear Sas users, > > I recently experienced a 'funny' problem due to use of function > mean() with sas 7, which I use on a Unix system. > > It might not be a new fact to most of you, but I would like to know > what you think of the potential precision problems of mean(). > > At the bottom of this message, I will give a short program along with > data, in which each subject should have a score (that score being the > average of 21 subscales) of 6. However, it turns out that all > subjects, when using the function mean(), do not have a score > of EXACTLY 6, as you can see from the logical variables computed > (cond*). > > This problem might be regarded as negligeable as it will not make any > practical difference in most day-to-day applications, but suppose > you want to do some sub-analyses for subjects with score > 6; > in the example given below, none fo the patients in this list should > be part of that sub-analysis, but it will not be the case... > > Was this bug ever reported? Should I write to SAS technical support? > Thanks for your thoughts. > > Patrick Belisle > Div. of Clinical Epidemiology > Montreal General Hospital > Montreal, Qc, CAN > > -- > > data mydata; > input x1-x21; > > cards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 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 > 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 > 2 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 > 0 0 0 1 0 0 1 1 0 0 1 0 0 0 1 0 0 0 0 1 0 > 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 > 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 1 1 > 0 1 0 1 0 0 0 0 0 0 0 0 2 0 0 1 0 0 0 1 0 > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 1 0 0 2 0 > 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 > 0 1 0 1 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 > 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 0 0 0 1 > 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 3 0 0 0 0 0 > 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 0 1 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 1 2 > 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 2 > ; > > data mydata; > set mydata; > > x_sum = sum(of x1-x21); > x_n = N(of x1-x21); > my_xtot = 21 * (x_sum / x_n); > xtot = 21 * mean(of x1-x21); > > format my_xtot xtot > 22.20; > > > my_cond = my_xtot > 6; > cond = xtot > 6; > > > proc freq; > tables my_xtot xtot; > tables my_xtot * my_cond / list; > tables xtot * cond / list; > run; > > -- > > Outputs excerpt: > > Cumulative Cumulative > MY_XTOT MY_COND Frequency Percent Frequency Percent > ---------------------------------------------------------------------- > 6.00000000000000 0 38 100.00 38 100.00 > > As you can see, the part above is correct (computing the mean 'myself'), > but the part below isn't (using mean() to compute the score)... > > Cumulative Cumulative > XTOT COND Frequency Percent Frequency Percent > > ------------------------------------------------------------------------ > 5.99999999999999 0 5 13.16 5 13.16 > 6.00000000000000 0 31 81.58 36 94.74 > 6.00000000000000 1 2 5.26 38 100.00 > > > Sent via Deja.com http://www.deja.com/ > Before you buy.


Back to: Top of message | Previous page | Main SAS-L page