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 (March 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 22 Mar 2002 16:29:03 -0500
Reply-To:   Frank Ivis <FIvis@CIHI.CA>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Frank Ivis <FIvis@CIHI.CA>
Subject:   precision of PROC FREQ
Content-Type:   text/plain; charset="iso-8859-1"

I happened to notice a very small difference in precision between the percentages calculated in PROC FREQ and SQL(the same also for data step). Is such a small difference to be expected or should the results be exact? In general, has anyone found different procs to give different results?

Code and output is below.

thanks in advance for any comments.

> Frank Ivis > Senior Analyst, Data Quality > Canadian Institute for Health Information > 90 Eglinton Ave. E., Suite 300 > Toronto, Ontario M4P 2Y3 > Tel: (416) 481-1616 ext. 3454 > Fax: (416) 481-2950 > Email: FIvis@cihi.ca > > title ' '; data work.hosp; input inst_id $ discharges; cards; 1001 340 1002 2670 1003 990 1004 1050 1006 887 1007 5896 1008 221 ; run;

proc sql; create table work.method2 as select inst_id, discharges, (discharges/sum(discharges))*100 as percent_discharges from work.hosp; quit;

proc freq data=work.hosp noprint; weight discharges; table inst_id/out=work.method4a(rename=(count=discharges percent=percent_discharges)); run;

data test; merge method2 (keep=inst_id percent_discharges rename=(percent_discharges=m1)) method4a (keep=inst_id percent_discharges rename=(percent_discharges=m4)); by inst_id; diff=m1-m4; run;

proc print data=test; format m1 m4 25.22; run;

The output is:

Obs inst_id m1 m4 diff

1 1001 2.8206404513024700000000 2.8206404513024700000000 0 2 1002 22.1503235440517000000000 22.1503235440517000000000 -3.5527E-15 3 1003 8.2130413140866100000000 8.2130413140866100000000 0 4 1004 8.7108013937282200000000 8.7108013937282200000000 0 5 1006 7.3585531773685000000000 7.3585531773685100000000 -8.8818E-16 6 1007 48.9132238261158000000000 48.9132238261158000000000 0 7 1008 1.8334162933466000000000 1.8334162933466000000000 0


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