I currently have a string variable (drugs) that contains a list of drugs prescribed at each line of treatment. I'm looking to create a new string that contains only the unique drugs from each line. In the example below, for patient 6, treatment line 3 would be "CARBOPLATIN + ETOPOSIDE".
Any ideas?
I'm currently trying to tweak some code found elsewhere, but currently unsuccessfully:
Any ideas?
Code:
clear input float(makeid line) str44 analysis_group 1 1 "CARBOPLATIN + ETOPOSIDE" 1 2 "CYCLOPHOSPHAMIDE + DOXORUBICIN + VINCRISTINE" 2 1 "CARBOPLATIN + ETOPOSIDE" 3 1 "CARBOPLATIN + ETOPOSIDE" 4 1 "CARBOPLATIN + ETOPOSIDE" 5 1 "CARBOPLATIN + ETOPOSIDE" 5 1 "CARBOPLATIN + ETOPOSIDE" 6 1 "CARBOPLATIN + ETOPOSIDE" 6 2 "PAZOPANIB" 6 3 "CARBOPLATIN + ETOPOSIDE" 6 3 "CARBOPLATIN" 7 1 "CARBOPLATIN + ETOPOSIDE" 8 1 "CISPLATIN + ETOPOSIDE" 9 1 "CARBOPLATIN + ETOPOSIDE" 10 1 "CISPLATIN + ETOPOSIDE" 11 1 "CARBOPLATIN + ETOPOSIDE" 12 1 "CARBOPLATIN + ETOPOSIDE" 13 1 "CARBOPLATIN + ETOPOSIDE" 14 1 "CARBOPLATIN + ETOPOSIDE" 15 1 "CARBOPLATIN + ETOPOSIDE" 16 1 "CARBOPLATIN + ETOPOSIDE" end
Code:
egen newid=group(tumourid line) foreach n in newid { local t `"`=analysis_group[`n']'"' local t2 : list uniq t replace analysis_group = `"`: list uniq t'"' in `n' }
Comment