I revised the dataset by adding correct unit in each dose field. I hope this helps and it should take care of the correct unit to dose issue. What I need help with is how to determine a new med added if it hasn't been taking in the previous encounters. An example of ID 109 shows med mtx taken since enc=1 and continued till enc 3, new med ssz added at enc 3 that has not been taken previously, and med_toc stopped at enc 3, so the note at enc 3 should indicate "Taking MTX 25 mg, added SSZ 2000 mg, stopped TOC". data have; infile datalines dsd truncover; input id:$11. enc:32. mtx:32. mtx_dose:$15. ssz:32. ssz_dose:$15. lef:32. lef_dose:$15. rtx:32. rtx_dose:$15. toc:32. toc_dose:$15.; datalines4; 102,1,0,,0,,0,,1,400 mg/m^,0, 102,2,0,,0,,0,,1,,0, 102,3,0,,0,,0,,1,400 mg/m^,0, 102,4,0,,0,,0,,2,,0, 102,5,,,,,,,,,, 106,1,0,,0,,1,20 mg,0,,0, 106,2,,,,,,,,,, 106,3,,,,,,,,,, 106,4,0,,1,2000 mg,1,20 mg,0,,0, 106,5,,,,,,,,,, 107,1,0,,0,,1,20 mg,1,400 mg/m^,0, 107,2,,,,,,,,,, 107,3,0,,0,,1,20 mg,1,400 mg/m^,0, 107,4,0,,0,,1,20 mg,1,200 mg/m^,0, 107,5,,,,,,,,,, 108,1,0,,0,,0,,0,,0, 108,2,0,,0,,0,,0,,0, 108,3,0,,0,,0,,0,,0, 108,4,0,,0,,0,,0,,0, 108,5,,,,,,,,,, 109,1,1,25 mg,0,,0,,0,,1,50 mg/kg 109,2,,,,,,,,,, 109,3,1,25 mg,1,2000 mg,0,,0,,2, 109,4,,,,,,,,,, 109,5,,,,,,,,,, ;;;; run; data want; set have; array c (*) mtx ssz lef rtx toc ; array d (*) mtx_dose ssz_dose lef_dose rtx_dose toc_dose ; array n (5) $ 25 _temporary_ ("MTX","SSZ","LEF","RTX","TOC"); length notes $ 200; if max(of c(*)) = 0 then notes="No current meds"; Else do i=1 to dim(c); if c[i]=1 then notes=catx(',',notes,catx(' ',"Taking",n[i],d[i])); if c[i]=2 then notes=catx(',',notes,catx(' ',"Stopped",n[i])); end; run; Thanks!
... View more