First, it's not a good idea to work with the same dataset "Baseline" so many times. For the merge to work, the datasets Baseline and POR must be sorted by PLANT and PO, for example: proc sort data=work.baseline; by PLANT PO; proc sort data=work.por; by PLANT PO; run; The first data step says to merge BASELINE and PO by matching PLANT and PO. If a unique combination of those variables is in BASELINE but not in POR, then those observations are output to BASELINE. (BASELINE is overwritten). To avoid overwriting you can change the first line to anything other than BASELINE, such as data work.baseline1. The first data step is more like a filter, I guess. If unique combinations of PLANT and PO are found in both datasets, then these are not output to BASELINE. The second data step requires A=1 and B=1 implicitly, so only matching combinations of PLANT and PO in each dataset are written to the output dataset BASELINE. If these are run sequentially, the second data step will find no matching observations because the output from the first data step will have removed any matching combinations of PLANT and PO from BASELINE.
... View more