1
votes

I want to do proc means on variable, which I should create in my dataset based on some other existing variables. Can I manage to do this in one procedure?

My hopeless trial was

data example;
do i =1 to 100;
   x=i**2;
   output;
end;
run;

proc means data = example mean;
var y = x + i;
run;

but it doesn't work. Is there a way to do this? Thanks for any help.

2

2 Answers

1
votes

You could try using the PROC SQL procedure which covers most of the summary stats producible using PROC MEANS

proc sql;
select mean(x+1) as y
from example;
quit;
1
votes

You could create a VIEW and do the means on that.

data example_v/view=example_v;
set example;
y=x+i;
run;

proc means data=example_v mean;
var y;
run;

VIEW is like a dataset, except that it isn't really run until it's needed - so even if example is very large it will take no time to create the view, and then approximately the same time to run the proc means as it would otherwise have with example.