How to compare to Two datasets and output the difference by using subject variable which is present in both domains using proc freq .
Dataset A;
subject
123
232
234
120
001
DATASET B
subject
123
232
234
If you just need to detect missing keys:
proc sort data=a;
by subject;
run;
proc sort data=b;
by subject;
run;
data
both
only_a
only_b
;
merge
a (in=in_a)
b (in=in_b)
;
by subject;
if in_a and in_b
then output both;
else if in_a
then output only_a;
else output only_b;
run;
If you need more than that, look at PROC COMPARE.
Why are you specifically stating the Proc Freq must be used? Proc freq takes a single data set as input.
Proc Compare is designed to compare data sets and can use BY processing to compare records based on values of common variables.
Your requirement of "output the difference by using subject variable" is not particularly clear as to the expected result.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.