SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Merging SAS Data Sets
Match-Merge Processing


The Execution Phase: Match-Merging Observations

After compiling the DATA step, SAS software sequentially match-merges observations by moving the pointers down each observation of each data set and checking to see whether the BY values match.

  • If Yes, the observations are written to the PDV in the order the data sets appear in the MERGE statement. (Remember that values of any like-named variable are overwritten by values of the like-named variable in subsequent data sets.) SAS software writes the combined observation to the new data set and retains the values in the PDV until the BY value changes in all the data sets.

matching observations found


  • If No, SAS software determines which of the values comes first and writes the observation containing this value to the PDV. Then the observation is written to the new data set.

no matching observation found


When the BY value changes in all the input data sets, the PDV is initialized to missing.


PDV initialized to missing

The DATA step merge continues to process every observation in each data set until it exhausts all observations in all data sets.



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement