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 (July 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 18 Jul 2006 09:25:57 -0400
Reply-To:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject:   Re: Total is not equal sum of subtotals
Comments:   To: Irin later <irinfigvam@YAHOO.COM>
Content-Type:   text/plain

Irin,

I didn't see any problem with your code. I got the expected sums running the following code...

data ppocost; infile cards; input@01 etg_family $char2. @04 allow_amt 2. ; cards; AA 10 AA 10 BB 20 BB 20 CC 30 CC 30 ; run;

Proc SQL ; Create Table MedCostPPO As Select ETG_FAMILY,sum(allow_amt) as sumtot From PPOcost Group By ETG_FAMILY; Quit;

proc print data = medcostppo; run;

data indcost; infile cards; input@01 etg_family $char2. @04 allow_amt 2. ; cards; AA 20 AA 20 BB 30 BB 30 CC 40 CC 40 ; run;

Proc SQL ; Create Table MedCostIND As Select ETG_FAMILY, sum(allow_amt) as sumtot From INDcost Group By ETG_FAMILY; Quit;

data IP; set MedCostPPO MedCostIND; run;

PROC SORT data=IP; BY ETG_FAMILY; run;

proc means data =IP noprint; by ETG_FAMILY; var sumtot; output out=IP_out sum=sumtotFinal; run;

Proc Rank data=IP_out Out=IP_final ties=low descending ; var sumtotFinal; Ranks rank_ALL; Run;

Is there additional information you could provide about what is unexpected in your results?

Jack

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Irin later Sent: Monday, July 17, 2006 3:48 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Total is not equal sum of subtotals

I run the following code: Proc SQL ; Create Table MedCostPPO As Select ETG_FAMILY,sum(allow_amt) as sumtot From PPOcost Group By ETG_FAMILY; Quit;

Proc SQL ; Create Table MedCostIND As Select ETG_FAMILY, sum(allow_amt) as sumtot From INDcost Group By ETG_FAMILY; Quit;

data IP; set MedCostPPO MedCostIND; run;

PROC SORT data=IP; BY ETG_FAMILY; run;

proc means data =IP noprint; by ETG_FAMILY; var sumtot; output out=OUT.IP sum=sumtotFinal; run;

Proc Rank data=OUT.IP Out=OUT.IP_ ties=low descending ; var sumtotFinal; Ranks rank_ALL; Run;

.... and the output is totally unexpected.

I have beaten my head trying to resolve the problem. The thing is that after I created dataset IP by concatenating two data sets MedCostPPO MedCostIND I tried to sum their sumtot into sumtotFinal through PROC MEANS and then calculate a rank.

However the total sumtotFinal is NOT equal the sum of subtotals (sumtot from MedCostPPO plus sumtot from MedCostIND). It differs dramatically.

What I am doing wrong?

Thank you in advance!

Irin

--------------------------------- Yahoo! Music Unlimited - Access over 1 million songs.Try it free.


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