You could use two calls to proc transpose and is pretty easy to extend to more variables.
data have;
infile cards dsd dlm='09'x;
input (Locker_ID Locations Person_A Person_B Person_C Person_A_Code Person_B_Code Person_C_Code)(:$32.);
cards;
101 Hampersmith, Silvershine Sam Copewell Amy Baker John Aston 123A 234B 345C
102 Coleridge, Brisbake Claude Tremaine Marissa Carter 567D 678E
103 Waterloop, Sturrey Brian Amble Charlie Springwater Mandy Smith 012G 134H 245J
;;;;
run;
proc transpose data=have out=flip(where=(not missing(col1))) name=vname;
by locker_id locations;
var person:;
run;
proc sort data=flip;
by locker_id locations vname;
run;
data flip;
set flip;
length _name_ $32;
pid = first(scan(vname,2,'_'));
if find(vname,'code','IT') then _name_ = 'Code';
else _name_ = scan(vname,1,'_');
run;
proc transpose data=flip out=flop(drop=_name_);
by locker_id locations pid;
var col1;
id _name_;
run;
... View more