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;
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.