It is hardly possible to answer the question without seeing the data. But your code has some issues:
1. It is almost always a bad idea to overwrite the dataset being processed.
data subject;
set subjects;
2. No length-statement for the new variable "second_major".
3. Using count will cause unexpected results, because
count("sand", "and") > 0
Using findw is better.
4. Remove
if count(major,'&')>0
and move both assignment statements into the first if-statement.
... View more