For example, I have a data set, with column name school subjects students are interested in. The old column would look like this: School Subjects: Health science and Math Biology Biology and Geology Arts and Computer Science Geology and Health Science Math My goal, is to extract the second school subject (ie Math or Geology) and put it in a new column to create the desired result: School Subject 1 School Subject 2 Health Science Math Biology Biology Geology Arts Computer Science Geology Health Science Math My solution was to create 2 conversion types, based on "and" and use if and then statement to separate the subjects: Conversiontype1 = scan(school_subjects, -2, " ");
Conversiontype2 = scan(school_subjects, 2, " ");
If conversiontype1 = "and" then school_subject1 = scan(school_subjects, -1, " ");
Else if conversiontype2 = "and" then school_subject2 = catx(" ", scan(school_subjects, -2), scan(school_subjects, -1));
else school_subject1 = school_subjects;
run; Is there a simpler way of doing this?
... View more