Help with finding a command in syntax for a very large dataset


I am working with a very large medicationprescription dataset (over 50 000 participants). In addition, every participant have on average 10 medications listed vertically, so that each participant occupy many cases vertically. I have to merge one file with the prescription data with another file containing operation year. When I merge the two files, for each participant there appears one line/case with the operation year and then the lines/cases including the different medications prescribed.

What I need is a syntax for copying the operation year that belongs to each participant-number. In a smaller dataset I would normally use the IF (subjectnr = 145667) op_year = 2004. commando. But then I have to write this command for 50 000 participants.
Is there a command in syntax that can do this automatically? A command that will say that "if x value on subjectnumber, then x value in op_year?

I would be very thankful for help, as I try to avoid spending a lot of time on this if there is an easier way to do it. Conversely, if the only way to do it is by writing the command for every participant, then I will get started on that instead of browsing the web endlessly for a simpler solution.

Thank you in advance!
I think the MERGE command with the TABLES option is what you want, where you match on participant ID. MERGE gives you options for keeping or dropping variables from the result as required. Have a look at the syntax command reference manual, which is available via the help. It would be more complex if some participants had more than one operation.

Hope this helps