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: 17,963

Re: Mean function in proc sql Vs Proc Mean

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: 10,550

Re: Mean function in proc sql Vs Proc Mean

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

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
  • 381 views
  • 0 likes
  • 3 in conversation