Checking for an ID in Each of “n” Files

Data set THREE is added to the mix to demonstrate how to approach this problem when there are more than two data sets. First, run Program 6-3 to create the new data set THREE.

Program 6-3. Creating a Third Data Set for Testing Purposes
DATA THREE;
   INPUT PATNO GENDER $ @@;
DATALINES;
1 M 2 F 3 M 5 F 6 M 12 M 13 M
;

Before developing a macro, let’s look at Program 6-4, which is a rather simple but slightly tedious program to accomplish the ID checks.

Program 6-4. Checking for an ID in Each of Three Data Sets (Long Way)
PROC SORT DATA=ONE(KEEP=PATNO) OUT=TMP1; BY PATNO; RUN; PROC SORT DATA=TWO(KEEP=PATNO) OUT=TMP2; BY PATNO; RUN; PROC SORT DATA=THREE(KEEP=PATNO) OUT=TMP3; BY PATNO; RUN; DATA _NULL_; FILE ...

Get Cody’s Data Cleaning Techniques Using SAS® Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.