Hi, I have a very simple question;
in case I am using multiple variables in var statement of proc means and I want to calculate average for all of them based on non zero values then How should approach the where statement in the proc means ?
Hi,
Please note that the post is 4 years old - start a new post. In answer to your question, why not go with Data _null_;'s suggestion of using arrays:
data have;
a=1; b=4; c=0; d=3; output;
a=4; b=4; c=1; d=5; output;
run;
data inter (keep=res1-res4);
set have;
array var{4} a b c d;
array res{4};
do i=1 to 4;
if var{i}=0 then res{i}=.;
else res{i}=var{i};
end;
run;
proc means data=inter;
var res1-res4;
output out=test;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.