I need to transpose each subset of subject. But after transpose I want each subject to have unique columns thus resulting in a wide data set. I don't think I can accomplish this with transpose alone. data have;
input subject count start end change;
datalines;
12345 1 20 35 1
12345 1 36 39 2
12345 1 40 45 0
23456 2 15 19 0
23456 2 20 24 1
34567 3 33 44 1
34567 3 45 50 2
45678 1 15 18 0
45678 1 19 22 1
run; So for example below if the first subject occupies columns st_1, ed_1, chg_1 through to st_3, ed_3, chg_3 Then the second subject will commence with st_4, ed_4, chg_4 through st_5, ed_5, chg_5 etc. But columns can be reused once the count variable resets to 1. Count resets after every 3 distinct subjects. Desired output; subject count st_1 ed_1 chg_1 st_2 ed_2 chg_2 st_3 ed_3 chg_3 st_4 ed_4 chg_4 st_5 ed_5 chg_5 st_6 ed_6 chg_6 st_7 ed_7 chg_7 12345 1 20 35 1 36 39 2 40 45 0 23456 2 15 19 0 20 24 1 34567 3 33 44 1 45 50 2 45678 1 15 18 0 19 22 1 Any suggestions?
... View more