DATA Step, Macro, Functions and more

PROC COMPARE for producing different totals between data sets

Reply
Frequent Contributor
Posts: 141

PROC COMPARE for producing different totals between data sets

I am trying to determine the best way compare 2 different data sets so I can pull totals from the differences.  In researching PROC COMPARE, this looks promising but it doesn't seem to work quite right for what I am looking for.

 

The main data set stores all information for loan records (balances, dates, etc.).  The comparison data set will be a data set that is updated each day with either new observations that are not in the master data set or observations which exist but have data points that have changed.  My goal is to be able to run a query to determine the differences between the 2 sets.  I will be looking for differences in loan count (i.e. there are 2 observations that are in the compare data set that are not in the main data set created the previous day) and balances (balances which may have been updated from the previous days data set).  I have tried the following code but the results just don't look right.  First of all, I am getting records that appear to have obersvations that all equal each other even though I am using the outnoequal option.  Next, new observations that are in the comparison data set that are not in the base data set are not showing up as differences.  I need to be able to see those new observations.

 

Here is the script I am running. 

 

proc compare out=msr.msr_daily_diff outnoequal outbase outcomp outdif /*noprint*/
			 base=msr.msr_master_table
			 compare=msr.msr_master_table_prevday;
by id;

run;

I hope this is enough information.  The results have proprietary data in them so I can't post them here.

Super User
Posts: 11,343

Re: PROC COMPARE for producing different totals between data sets

Posted in reply to elwayfan446

I think that you might be better off combining the two sets, adding a variable to indicate the source and then use a reporting procedure such as Proc Report to request statistics grouped by that source variable.

Ask a Question
Discussion stats
  • 1 reply
  • 154 views
  • 0 likes
  • 2 in conversation