sas vs spss output

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

sas vs spss output

i did an analysis with SAS and performed the same with SPSS and i got slightly different values for the mean (+/-0.01) and different values for the std (+/- 2.0). does this mean that i might have missed something out in one of the analyses or is this normal to have different descriptive statistics??


Accepted Solutions
Solution
‎04-23-2014 12:40 PM
Super User
Super User
Posts: 6,500

Re: sas vs spss output

You used the wrong STD function in Excel.  In Office 2010 you can choose between STDEV.P and STDEV.S.  The first one uses the N for the denominator when calculating variance instead of N-1.  So the value will also be lower than the sample standard deviation calculated by SAS.

View solution in original post


All Replies
Trusted Advisor
Posts: 1,204

Re: sas vs spss output

Can you share your code used for both SAS & SPSS and description of variables used for this analyis?

Contributor
Posts: 31

Re: sas vs spss output

data crossoverdesign;                                                                                                                                                                                                                                           
   infile datalines delimiter=',';                                                                                                                                                                                                                              
   input group Id StdTyp Period Trtgrp @;                                                                                                                                                                                                                       
   do d=1 to 3;                                                                                                                                                                                                                                                 
      do r=1 to 3;                                                                                                                                                                                                                                              
         input sbp dbp @;                                                                                                                                                                                                                                       
         if sbp eq 999 then sbp=.;                                                                                                                                                                                                                              
         if dbp eq 999 then dbp=.;                                                                                                                                                                                                                              
         output;                                                                                                                                                                                                                                                
         end;                                                                                                                                                                                                                                                   
      end;                                                                                                                                                                                                                                                      
   datalines;                                                                                                                                                                                                                                                   
1,3,1,1,1,134,82,122,80,118,80,112,76,130,84,120,82,114,76,104,74,114,76                                                                                                                                                                                       
1,3,1,2,2,113,61,116,72,115,67,122,70,136,76,128,72,122,72,126,72,123,71                                                                                                                                                                                       
1,4,2,1,3,142,90,134,88,134,84,122,76,116,76,114,74,122,84,124,78,116,80                                                                                                                                                                                       
1,4,2,2,1,128,86,133,81,135,81,129,83,116,74,130,80,138,84,140,80,134,74                                                                                                                                                                                       
1,5,1,1,1,134,78,138,84,126,80,122,74,120,76,122,78,140,82,134,84,136,84                                                                                                                                                                                       
1,5,1,2,2,126,76,122,74,116,76,134,82,126,88,130,84,132,78,128,82,126,78                                                                                                                                                                                       
1,8,2,1,3,112,72,114,70,116,70,120,78,122,76,116,76,118,72,113,75,113,73                                                                                                                                                                                       
1,8,2,2,1,116,72,106,76,110,72,125,75,131,73,126,78,110,68,109,67,105,71                                                                                                                                                                                       
2,9,1,1,2,116,70,112,72,108,70,124,70,110,70,112,74,114,78,120,72,116,76                                                                                                                                                                                       
2,9,1,2,1,102,60,104,64,104,66,110,74,107,77,112,74,104,64,113,75,102,70                                                                                                                                                                                       
2,10,1,1,2,109,73,107,77,104,80,110,74,114,74,110,74,119,79,119,75,112,80                                                                                                                                                                                      
2,10,1,2,1,118,78,117,83,118,82,108,72,106,70,98,70,117,81,110,78,110,80                                                                                                                                                                                       
1,14,1,1,1,116,64,97,61,100,60,118,73,125,77,119,69,106,70,107,73,110,70                                                                                                                                                                                       
1,14,1,2,2,114,70,110,72,112,76,100,66,113,73,100,68,116,74,112,74,112,72                                                                                                                                                                                      
2,22,3,1,2,122,78,114,76,114,72,110,76,102,68,105,73,116,68,106,66,106,72                                                                                                                                                                                      
2,22,3,2,3,102,64,112,74,120,80,112,74,100,78,116,72,95,67,100,70,100,70                                                                                                                                                                                       
2,25,3,1,2,102,60,94,62,94,66,96,62,103,65,103,61,110,70,121,71,125,77                                                                                                                                                                                         
2,25,3,2,3,98,60,101,65,96,64,99,59,101,65,98,60,102,62,96,68,104,62                                                                                                                                                                                           
2,27,1,1,2,126,80,130,80,120,78,122,80,128,74,122,82,128,78,121,77,123,77                                                                                                                                                                                      
2,27,1,2,1,116,76,120,72,120,74,134,84,136,88,128,84,136,86,136,82,132,80                                                                                                                                                                                      
1,29,1,1,1,111,67,110,72,106,66,95,65,105,65,104,62,96,58,98,64,100,60                                                                                                                                                                                         
1,29,1,2,2,109,71,112,72,110,72,94,62,96,62,98,60,108,70,102,70,100,66                                                                                                                                                                                         
1,30,3,1,3,110,62,111,61,99,55,110,62,110,62,112,62,104,64,104,64,108,60                                                                                                                                                                                       
1,30,3,2,2,116,68,114,64,114,64,102,60,100,56,106,56,116,66,108,62,108,64                                                                                                                                                                                      
1,31,2,1,3,134,82,136,72,128,72,130,80,131,73,129,75,134,82,132,78,132,74                                                                                                                                                                                      
1,31,2,2,1,122,74,128,78,124,80,126,78,126,72,128,78,126,82,132,80,136,80                                                                                                                                                                                      
2,32,2,1,1,114,66,106,68,106,66,122,72,130,74,124,76,118,62,121,77,116,72                                                                                                                                                                                      
2,32,2,2,3,104,62,103,67,102,66,109,69,106,66,104,66,114,70,108,70,112,72                                                                                                                                                                                      
1,33,1,1,1,156,86,154,76,144,86,148,88,140,88,142,86,144,90,132,86,140,86                                                                                                                                                                                      
1,33,1,2,2,168,94,146,96,154,92,157,89,158,90,158,90,133,83,142,84,146,88                                                                                                                                                                                      
2,34,1,1,2,122,76,116,74,116,76,127,77,114,72,114,70,126,72,116,66,118,72                                                                                                                                                                                      
2,34,1,2,1,126,80,126,80,120,82,113,71,116,74,108,74,110,72,109,71,110,78                                                                                                                                                                                      
2,36,2,1,1,96,60,104,66,94,64,100,70,100,74,106,74,96,64,92,62,93,59                                                                                                                                                                                           
2,36,2,2,3,100,72,104,74,108,78,103,63,104,62,98,64,98,64,98,64,100,72                                                                                                                                                                                         
2,37,1,1,2,118,74,114,70,112,68,110,72,110,70,113,69,116,76,122,76,116,74                                                                                                                                                                                      
2,37,1,2,1,126,84,127,83,120,82,126,78,125,77,118,80,106,64,104,68,110,68                                                                                                                                                                                      
2,39,3,1,2,128,86,124,84,126,84,132,80,130,86,134,82,114,74,112,74,112,82                                                                                                                                                                                      
2,39,3,2,3,123,79,120,82,124,84,106,68,102,72,102,72,108,76,112,74,106,76                                                                                                                                                                                      
1,40,2,1,3,96,64,106,70,99,67,110,60,96,62,86,60,98,62,92,60,91,63                                                                                                                                                                                             
1,40,2,2,1,121,77,118,76,116,82,104,68,107,69,108,76,99,75,98,64,98,70                                                                                                                                                                                         
2,42,3,1,2,138,80,136,74,133,79,154,88,144,80,149,81,134,84,127,77,126,74                                                                                                                                                                                      
2,42,3,2,3,126,76,125,75,121,73,130,76,118,80,118,68,132,74,118,70,126,74                                                                                                                                                                                      
1,49,3,1,3,90,62,94,64,86,60,90,60,92,60,86,56,86,58,87,59,90,60                                                                                                                                                                                               
1,49,3,2,2,88,64,88,60,92,66,86,60,94,60,92,64,88,56,92,62,92,62                                                                                                                                                                                               
1,50,1,1,1,114,68,106,66,106,70,100,66,100,70,105,63,112,64,98,64,110,64                                                                                                                                                                                       
1,50,1,2,2,98,62,96,58,96,56,106,66,98,66,99,63,105,67,102,58,100,62                                                                                                                                                                                           
1,52,2,1,3,129,67,120,68,130,72,121,67,118,66,114,68,114,70,111,67,114,68                                                                                                                                                                                      
1,52,2,2,1,118,70,120,70,106,72,112,68,116,68,118,70,108,66,108,68,108,68                                                                                                                                                                                      
2,53,1,1,2,112,84,112,82,114,84,110,76,110,74,112,78,112,88,114,84,114,84                                                                                                                                                                                      
2,53,1,2,1,120,82,124,86,112,82,140,88,131,91,128,92,112,78,114,88,121,87                                                                                                                                                                                      
2,57,1,1,2,124,82,132,84,132,90,118,70,120,80,110,72,130,80,138,80,131,79                                                                                                                                                                                      
2,57,1,2,1,136,88,136,86,142,90,148,88,142,90,140,94,142,72,138,84,148,84                                                                                                                                                                                      
2,58,3,1,2,94,74,98,66,86,68,102,70,98,66,90,64,86,64,96,66,94,66                                                                                                                                                                                              
2,58,3,2,3,102,66,100,74,96,68,96,70,103,73,99,73,102,74,100,68,94,68                                                                                                                                                                                          
1,61,2,1,3,144,92,139,83,142,90,134,92,138,88,134,90,136,90,148,102,142,92                                                                                                                                                                                     
1,61,2,2,1,146,94,144,92,149,93,138,92,126,90,128,92,134,90,132,90,124,88                                                                                                                                                                                      
1,62,3,1,3,104,64,100,66,96,64,100,66,100,70,103,67,104,70,102,66,102,68                                                                                                                                                                                       
1,62,3,2,2,106,70,108,68,98,74,106,70,102,68,102,70,103,65,100,64,96,64                                                                                                                                                                                        
;;;;                                                                                                                                                                                                                                                           
run;                                                                                                                                                                                                                                                           
proc sort data=crossoverdesign;                                                                                                                                                                                                                                 
   by Id   period;                                                                                                                                                                                                                                                
run;                                     

PROC means;                                                                                                                                                                                                                                                
   class StdTyp Period Trtgrp;                                                                                                                                                                                                                             
   VAR SBP DBP;                                                                                                                                                                                                                                            
OUTPUT OUT=A MEAN(SBP DBP)=Msbp Mdbp std(SBP DBP)=Stdsbp Stddbp N(SBP)=n1 N(SBP)=n2;                                                                                                                                                                      

run; 

Contributor
Posts: 31

Re: sas vs spss output

  EXCEL OUTPUT   (I meant excel)

        

                SBP period1               SBP period2

                trt1          trt2               trt1         trt2

N

6.000

6.000

7.000

7.000

MEAN

118.778

118.907

120.508

117.476

STD

15.999

19.017

11.684

5.829

SAS OUTPUT

                SBP period1               SBP period2

                trt1          trt2               trt1         trt2

N

6.000

6.000

7.000

7.000

MEAN

118.778

118.907

120.508

117.476

STD

16.4439

18.7035

12.9177

7.29971


Solution
‎04-23-2014 12:40 PM
Super User
Super User
Posts: 6,500

Re: sas vs spss output

You used the wrong STD function in Excel.  In Office 2010 you can choose between STDEV.P and STDEV.S.  The first one uses the N for the denominator when calculating variance instead of N-1.  So the value will also be lower than the sample standard deviation calculated by SAS.

Contributor
Posts: 31

Re: sas vs spss output

what if i had to use SPSS? which of the outputs is it likely that i will get? or do i have to specify the std format in SPSS too?

Super User
Super User
Posts: 6,500

Re: sas vs spss output

All statistics packages (most likely even those that run inside Excel) will default to using N-1. 

In PROC MEANS you can add the VARDEF option if want to change the denominator used in calculating variance (STD is just SQRT(VAR)).

Trusted Advisor
Posts: 1,204

Re: sas vs spss output

SPSS divides by n-1 when computing a variance

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 333 views
  • 6 likes
  • 3 in conversation