Learning SAS? Welcome to the exclusive online community for all SAS learners.

Mean function in proc sql Vs Proc Mean

Reply
Occasional Contributor
Posts: 9

Mean function in proc sql Vs Proc Mean

Hi,

Can anyone let me know if there is any difference in MEAN function using in proc sql and using Proc Mean.

I can see output from both the process are different. I don't understand how proc sql is treating mean function.

ThanksSAS

Super User
Posts: 19,822

Re: Mean function in proc sql Vs Proc Mean

Posted in reply to SAS_Programmer

They should be the same.

The following should generate the same results.

proc means data=sashelp.class mean;

var weight;

run;

proc sql;

select mean(weight) as mean from sashelp.class;

quit;

If you're getting different results post your code/data.

Super User
Posts: 11,343

Re: Mean function in proc sql Vs Proc Mean

Posted in reply to SAS_Programmer

The values DISPLAYED may have different numbers of decimals because of the formats that each defaults to using.

Create output sets and use proc compare.

Occasional Contributor
Posts: 9

Re: Mean function in proc sql Vs Proc Mean

Posted in reply to SAS_Programmer

Hi ,

Please find the code which I have used to generate mean.

Please Note I have processed 1000 + file but this kind of issue I have observed in only 20+ file:

proc means data=table_name. ;

var FA2;

output out=FA2;

run;

proc sql;

create table mean_val as

select mean(FA2) as mean_val from table_name.

;

quit;

  1. SAS SQL Value 32589142.76
  2. Proc Mean report 32589148.74

Given the output from SAS proc sql and proc mean

Let me know if you have any query.

Ask a Question
Discussion stats
  • 3 replies
  • 608 views
  • 0 likes
  • 3 in conversation