I have following dataset
data height;
input name $ var $ value;
datalines;
John test1 175
Peter test1 180
Chris test1 140
John test2 178
Peter test2 182
Chris test2 148
;
run;
I would like to make mean value of 2 tests for each students
I able to make a new variable named mean_v_John by following
proc sql;
select mean(value) into: mean_v_John
from height
where name = 'John';
quit;
%put &mean_v_John.;
With output:
2216 %put &mean_v_John.;
176.5
Problem: How can i auto detect how many students and create variable with &mean_v_NAME? In this example there will be 3 variables.
If you start of with calculating the mean for each student, you can use that table to assign the macro variables with the
call symput
routine. Like: