Help using Base SAS procedures

Proc sql average vs proc means;

Reply
Occasional Contributor
Posts: 8

Proc sql average vs proc means;

Hello there,

 

There is a statement in stat proc means that I am trying to find the equivalence in proc sql average.

If I want to compute the means and including missing values

proc means= data mean missing;

 var y;

output out=yout mean= Avg  std=SD;

run;

 

proc sql;

select *, avg(y)

from data;

quit.

Is there any way to include a missing statement in proc sql ?

Thanks in advance

 

 

 

 

PROC Star
Posts: 8,164

Re: Proc sql average vs proc means;

Since proc mean's missing option only concerns missing class variables, there would be no difference in using sql's avg or proc means.

 

Art, CEO, AnalystFinder.com

 

Super User
Posts: 6,771

Re: Proc sql average vs proc means;

[ Edited ]

And on a related note, the sample PROC MEANS that you posted would produce the same results, whether or not the MISSING option is present.  You might need to see a few examples of how MISSING affects the results ... as @art297 mentioned, those examples will include a CLASS statement,.

 

Just curious, how are you picturing that the results would change if missing values are included vs. excluded?

Super User
Posts: 23,713

Re: Proc sql average vs proc means;

It's not clear how you want to include missing. If you essentially want them treated as 0, it's easiest to recode them and summarize on that, or you can use the sum() / COUNT() of the total number of rows, which would include the missing in the denominator. 

 


@Alass006 wrote:

Hello there,

 

There is a statement in stat proc means that I am trying to find the equivalence in proc sql average.

If I want to compute the means and including missing values

proc means= data mean missing;

 var y;

output out=yout mean= Avg  std=SD;

run;

 

proc sql;

select *, avg(y)

from data;

quit.

Is there any way to include a missing statement in proc sql ?

Thanks in advance

 

 

 

 


 

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