Your syntax for passing a variable list to a function is wrong. To pass a variable list to a function in SAS you need to use the of
keyword. MAX(of m1-m5)
.
Your code is actually calculating the difference between M1 and M5 and since MAX() only has one parameter SAS sees this as a call to the SQL aggregate function MAX()
and not a call to the SAS function MAX(,)
for finding the max of two or more numbers.
But you cannot use variable lists in PROC SQL, so you will need to list the individual variables.
proc sql;
select id,m1,m2,m3,m4,m5
, max(m1,m2,m3,m4,m5) as max_marks
from data1
;
quit;