Merging Files with Either Student ID or Social Security Number

by Dr. Alex Yu


I want to merge two files. File A is a payroll record with employee ID. File B is a student profile record with both student ID and social security number (SSN). Some students use their student ID as the employee ID but some use SSN. I want to merge File A and File B by either student ID or SSN.

* Assign employee ID as student ID in File B *
Data temp1;  set file_b;
			eid = sid;
			proc sort; by eid;

* First merge with student ID *
Data one; merge file_a temp1; by eid;

* Assign employee ID as SSN in File B *
Data temp2; set file_b;
			eid = ssn;
			proc sort; by eid;

* Second merge with SSN *
Data two; merge file_a temp2; by eid;

* Concatenate without duplicates *
Data three; set one two; 
		proc sort nodupkey; by eid;



Simplified Navigation

Table of Contents

Search Engine