If you want an easy solution, change how you construct M02, limiting it to one observation per value of A. For example: data m02 (index=(a)); set m02; by a; if last.a; run; Then your final step should work just fine. Note that there are complications that you have not even tried to illustrate, using your current approach. For example, try constructing M01 having 2 observations with A=2, and examine the values you get for C. (Then try it with 3 observations with A=2.) In your final solution, you may end up adding the UNIQUE option after KEY=A. Good luck. ... Now that I've re-read the problem, this solution won't work. The poster who suggested you use MERGE is correct. This problem is ideal for MERGE, possibly adding the use of IN= variables. In the long run, you can't avoid learning MERGE when you program in SAS, so this might be the right time when you have a problem that requires it. (Or is the whole point of the problem to learn just how cumbersome the solution would be if you are not allowed to use MERGE when it is the right tool for the job?)
... View more