data ccc;
set aaa end=last;
by site name notsorted;
if _n_=1 then call execute("data ddd(keep=oid x2 name site: drop=site); merge ");
if first.site then call execute(cats("ccc(where=(site=",site,") rename=(_x1=site",site,"))"));
if last then call execute(" ccc(where=(^missing(x2)) keep=name_order x2 oid) ; by name_order; run;");
if first.site then name_order=0;
if first.name then do; _x1=catx(" ",x1); name_order+1; end;
else if not first.name then _x1=catx(" ",_x1,x1);
if last.name;
retain _x1 ;
run;