Compare in SAS proc

Firstly, I know almost nothing about SAS, and I'm not a programmer, but an accountant, but here it is:

I am trying to compare two datasets to determine the differences between them, so I use the "proc compare" command as follows:

proc compare data=table1 compare=table2 criterion=.01; run; 

This works fine, but it is compared by row and order, so if table 2 does not have a row halfway, all entries after this row will be returned as unequal.

How can I ask the comparison to be done based on the variable, so that the proc comparison finds the value associated with the variable X in table 1, and then ensures that the same variable X in table 2 has the same value?

+4
source share
1 answer

The ID statement in PROC COMPARE is used to match strings. This code may work for you:

 proc compare data=table1 compare=table2 criterion=.01; id X; run; 

You may need to use PROC SORT to sort data by X before executing PROC COMPARE. Refer to the PROC COMPARE documentation for details on the ID instruction to determine whether to sort or not.

Here is the link to the PROC COMPARE documentation:

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000057814.htm

+4
source

Source: https://habr.com/ru/post/1301854/


All Articles