Proc Summary , Proc SQL Different results

Proc Summary , Proc SQL Different results

Post by Sekha » Wed, 19 Oct 2005 22:13:09


Hi
Please take a look at two summaries, one using Proc Summary and One
using Proc sql. I got different results using these two. Until now I am
thinking that these two codes are interchangeble. That is I can use one
in place of other. It could be that I am missing something here. Proc
sql gave me the correct results.Any pointers please?

proc summary data=test1;
class var1 speciality;
var samp01-samp12;
output out=test2(drop= _TYPE_ _FREQ_) sum=;
run;

proc sql;
create table test3 as select var1,speciality,sum(samp01) as
samp01,sum(samp02) as samp02,sum(samp03) as samp03,sum(samp04) as
samp04,
sum(samp05) as samp05,sum(samp06) as samp06,sum(samp07) as
samp07,sum(samp08) as samp08,sum(samp09) as samp09,
sum(samp10) as samp10,sum(samp11) as samp11,sum(samp12) as samp12 from
test1 group by var1,speciality;
quit;
 
 
 

Proc Summary , Proc SQL Different results

Post by HERMANS » Wed, 19 Oct 2005 23:08:30

Sekhar:
The NWAY option of PROC SUMMARY selects the top-level summary. Results
with the NWAY option should match SAS SQL GROUP BY results for the same
class.
Sig

-----Original Message-----
From: XXXX@XXXXX.COM [mailto: XXXX@XXXXX.COM ]
On Behalf Of Sekhar
Sent: Tuesday, October 18, 2005 9:13 AM
To: XXXX@XXXXX.COM
Subject: Proc Summary , Proc SQL Different results


Hi
Please take a look at two summaries, one using Proc Summary and One
using Proc sql. I got different results using these two. Until now I am
thinking that these two codes are interchangeble. That is I can use one
in place of other. It could be that I am missing something here. Proc
sql gave me the correct results.Any pointers please?

proc summary data=test1;
class var1 speciality;
var samp01-samp12;
output out=test2(drop= _TYPE_ _FREQ_) sum=;
run;

proc sql;
create table test3 as select var1,speciality,sum(samp01) as
samp01,sum(samp02) as samp02,sum(samp03) as samp03,sum(samp04) as
samp04,
sum(samp05) as samp05,sum(samp06) as samp06,sum(samp07) as
samp07,sum(samp08) as samp08,sum(samp09) as samp09,
sum(samp10) as samp10,sum(samp11) as samp11,sum(samp12) as samp12 from
test1 group by var1,speciality; quit;

 
 
 

Proc Summary , Proc SQL Different results

Post by Joep » Wed, 19 Oct 2005 23:15:38

Sekhar,

I notice that you do not use the NWAY option on proc summary. This
option will give you the summaries on the toplevel (_type_ = 1)only and
in my opinion will give you the same results as your proc sql.

Regards, Joep