anyone familiar with data all stored in one cell with delimiters and successfully breaking them down into their own cell? For example, we have all drugs that the patient started on in one cell in this format: Isoniazid[1] | Rifampin[2] | Pyrazinamide[3] | Ethambutol[4] | Streptomycin[5] | Rifapentine[6] | Ethionamide[7] | Amikacin[8] | Kanamycin[9] | Streptomycin[10] If there is a blank within the repeating block, no data will be written into the repeating block like below: Isoniazid[1] | Pyrazinamide[3] | Ethambutol[4] | Streptomycin[5] | Ethionamide[7] | Amikacin[8] | Kanamycin[9] | Streptomycin[10] my issue is creating a repeating block that will split the cells that have missing information like above; %macro repeating_block (input=have var=Drug, output=want) ; proc sql noprint; select max(countw(Drug_ALL,'|')) into : max from have; quit; data want; set have; array drug_{&max} $ 100; array iteration{&max}8 _temporary_ ; do i=1 to &max; drug_clean=scan(drug_all, i, '|'); if drug_clean ne '' then do; drug=scan(drug_clean, 1, '['); iter_num=input(scan(scan(Drug_clean,2,'['), 1, ']'), 8.); if iter_num>0 and iter_num<=&max then do; Deug_[iter_num]=trim (drug); iteration[iter_num] = iter_num; if drug_clean='' then drug_[iter_num]=""; end; end; end; drop iter_num drug_clean i; run; %mend repeating_block; %repeating_block;
... View more