Hello good people,

I need help with this situation here. Please give it a look.

Below is my data, I have 100s of patients, and many more variables value1 value2 value3......etc.

Now for each patient, I would like to create a row that has variables patientid date1 base_date2 base_value1 base_value2.....base_value25 final_date2 final_value1 final_value2 final_value3...final_value25

Note: date1 is same for each unique patient. base & final are from variable base_final . Some patients have only base or final , in such case base_value/final_value could be missing in the wide data form. base_final has only base or final as observations.



Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input int(PatientId date1 date2) byte(value1 value2) str5 base_final
10664 20405 20396 3 3 "base"
10664 20405 21732 2 6 "final"
11412 22446 22460 2 4 "base"
11412 22446 22596 2 2 "final"
11543 21621 21621 1 4 "base"
11543 21621 22677 1 2 "final"
11551 21977 21958 6 1 "base"
end
format %td date1
format %td date2