proc sql;
create table temp as
select distinct School_name, Academic_year
from have
order by School_name, Academic_year
;
quit;
Proc transpose data=temp out=trans;
by school_name;
var Academic_year;
run;
data want;
set trans;
length Yearlist $ 200; /* this needs to be set long enough to hold longest expected list which would be roughly 10 times the numer of academic years
that might be involved)
Yearlist = catx(',', of col: );
drop col: ;
run;
This code is using a variable list Col: which means all of the variables whose names start with Col . The colon must be immediately after the last letter of the name stem.
The length of the yearlist is # of academic years* (9 +1) . The 9 is how many characters to hold something like 2016-2017, plus 1 for the comma =>10* the number of academic years that might be involved. Look at the TRANS set to see how many years. There will be variables named COL1 -COLn, one for each year. The school with the most years will set the maximum number of years.
Untested because no actual data set provided.