Joining Two Files
Equal Join
Problem
Solution
/* Assume that in this case you have affiliate ID in both files. */ Data file_a; ... temp_id = ssn; proc sort; by id; Data file_b; ... temp_id2 = ssn; proc sort; by id; Data all; merge file_a file_b; by id; if temp_id = temp_id2; /* You may also use the following alternate approach. */ /* This method uses flags in both files */ Data file_a; ... flag_a = 1; proc sort; by id; Data file_b; ... flag_b = 1; proc sort; by id; Data all; merge file_a file_b; by id; if flag_a = 1 and flag_b = 1;
Left/Right Join
Problem
Solution
/* Assume that in this case you have affiliate ID in both files. */ Data file_a; ... infile_a = 1; proc sort; by id; Data file_b; ... proc sort; by id; Data all; merge file_a file_b; by id; if infile = 1;/* The alternate approach is */ proc sort data=file_a; by id; proc sort data=file_b; by id; Data all; merge file_a(IN=A) file_b(IN=B); by id; if A;
NavigationIndexSimplified NavigationTable of ContentsSearch EngineContact
|