I'm sure there's a better way to do this, but this appears to work. I'm assuming your date field will be dynamic, so you will need to figure out how to do that, but here's a start: data have;
infile cards expandtabs truncover;
input id $2. rx1 rx2 rx3 rx4 rx5 & 2.;
cards;
1 5 6 8 10 4
2 0 2 4 7 6
4 1 1 3 9 2
7 3 2 4 6 3
6 4 2 5 6 8
;
proc sort data=have;
by id;
run;
proc format;
value $rxf
"rx1" = "Sept-2019"
"rx2" = "Aug-2019"
"rx3" = "Jul-2019"
"rx4" = "Jun-2019"
"rx5" = "May-2019"
;
proc transpose data=have
out=want (rename=(col1=Rx))
name=date1;
by id;
var rx1 rx2 rx3 rx4 rx5;
run;
data want_format (drop=date1 rename=(date2=date1));
set want;
length date2 $9.;
date2 = put(date1, $rxf.);
run; I ran a proc compare and the results were the same.
... View more