I have a college data, problem is finding if the same id, same course1 and course2 have next term or not. I have the table as below first 4 variables: id, term, course1 and course2. I am trying to create 5th variable 'nextterm'. Terms are like this: 201010-201020-201030-201110-201120-201130-201210,... so on. So id=21, course1 and course 2 are same MAT 51 for 201010 AND 201020. So 201010 is going to be Yes, 201020 is going to be No.
id term course1 course2 nextterm
21 201010 MAT 41 No
21 201010 MAT 51 Yes
21 201020 MAT 51 No
21 201020 SPC 13 No
29 201130 pos 94 Yes
29 201210 pos 94 No
Ok, this is the updated answer, it requires some understanding of SQL at certain level, it works if your data volume is not too large. Please note, I have converted the term into number in the incoming dataset, but it can also be done on the fly. If you feel it runs too slow, then I suggest 1. resort your data by decending term within id, 2. DOW or Hash should be sufficient.
Here is a better solution. It sets up a Hash object in the first DOW to store all of the term, course information within the same ID, then in the second DOW to check if your condition meets. It does not require a sort if all of IDs stay together (clustered). For details, please refer to SAS Hash docs.