Here's another just-for-fun approach, suitable (without further additions) only for small examples like your sample data or sashelp.class, if any:
proc sql noprint;
select catx(':',department,employee,department) into :x separated by '|'
from employees
order by department, employee;
create table want as
select department, scan(substr(tranwrd("&x",cats(':',department,'|',department,':'),', '),find("&x",cats(department,':'))),2,':') as emp_list
from (select distinct department from employees);
quit;
... View more