Thursday 1 December 2016

Handling with Match-Merging Data Sets - With No common variable.

Match-Merging Data Sets That Lack a Common Variable



Table   Data Sets and Variables That Are Used in Match-Merge Examples

These data sets do not share a common variable. However, COMPANY and FINANCE share the variable Name. Similarly, FINANCE and REPERTORY share the variable IdNumber. 
Therefore, as the next program shows, you can merge the data sets into one with two separate DATA steps. As usual, you must sort the data sets by the appropriate BY variable. (REPERTORY is already sorted by IdNumber.)


/* Sort FINANCE and COMPANY by Name */
proc sort data=finance;
by Name; 
run;

proc sort data=company; 
by Name;
run;

/* Merge COMPANY and FINANCE into a */
/* temporary data set. */
data temp; merge company finance; by Name; run; proc sort data=temp; by IdNumber; run;




/* Merge the temporary data set with REPERTORY */ 

data all;
merge temp repertory;
by IdNumber;
run;

proc print data=all;
title 'Little Theatre Complete Casting information';
run;



In order to merge the three data sets, this program performs the following tasks:·       \Sorts FINANCE and COMPANY by Name
·       merges COMPANY and FINANCE into a temporary data set, TEMP
·       sorts TEMP by IdNumber
·       merges TEMP and REPERTORY by IdNumber



No comments:

Post a Comment