COMPARE
From sasCommunity
Original entry by Dave Haans, Toronto Region -- Statistics Canada Research Data Centre
[edit] Introduction
Proc Compare allows one to compare two variables, whether in the same dataset or in different datasets.
[edit] Using PROC COMPARE to determine new additions to a dataset
The use of proc compare is used here to determine if new observations have been added to a dataset, and to output only those new observations. This can be used to compare datasets based on a log, for example, to identify any new additions to the log.
This method requires that the order of the observations is unchanged. In other words, it only works if the new observations were appended to the old observations, and only if the data was not subsequently sorted.
Code:
data basedata; length num 3 name $ 20; input num name; datalines; 1 Jan 2 Fred 3 Dave ; run;
data newnames; length num 3 name $ 20; input num name; datalines; 1 Jan 2 Fred 3 Dave 4 Elaine 5 Sally ; run;
/* Using both outall and outnoequal results in unique observations being output */ proc compare base=basedata compare=newnames out=unique outall outnoequal noprint; id num; run;
proc print data=unique; run;
Output:
Obs _TYPE_ _OBS_ num name 1 COMPARE 4 4 Elaine 2 COMPARE 5 5 Sally
