Your displayed data set doesn't have duplicates that I can see. This won't give you the formatting youw ant but it's close. The label of 'without adverse event likely belongs to the TRTAN column.
proc transpose data=have out=want; by trtan; id aesevn; idlabel aesev; var count; run;
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and lock in 2025 pricing—just $495!