- This program will require the following program to “Cross-Walk” two or more datasets:
%MACRO CRWLK (V,V1);
PROC CONTENTS
DATA=&V1
NOPRINT
OUT= &v
(KEEP= name type format label length engine nobs);
RUN;
DATA &V;
SET &V;
label_&v1=label;
&v=”&v1″;
DROP label;
RUN;
%MEND;
2. Then you will need to put this in your program:
%CRWLK(A,REG1); %CRWLK(B,REG2); %CRWLK(C,REG3);
PROC SORT DATA=A; BY name; RUN;
PROC SORT DATA=B; BY name; RUN;
PROC SORT DATA=C; BY name; RUN;
DATA Dataset1_set3;
MERGE A B C;
BY name;
track=compress(trim(a)|| trim(b)|| trim(c));
IF track=”REG1REG2REG3″ THEN variable_track=”variables found in all 3 datasets”;
*ELSE IF track=”REG1″ THEN variable_track=”variables found in set1 only”;
*ELSE IF track=”REG2″ THEN variable_track=”variables found in set2 only”;
*ELSE IF track=”REG3″ THEN variable_track=”variables found in set3 only”;
*ELSE variable_track=”variables found in sets 2 or 3″;
RUN;
3. UNCOMMENT/COMMENT out above to allow indication of which set is missing a variable.