Dear all,

I am trying to run a double data comparison from a Redcap export and need some additional help.

Needs: I would like to export a final list of all variables that do not match so that I can send to Research Personnel and they can clean by referencing the excel file. I've run a loop that creates a suffix for "data entry 1" (_p1), merged the two files based off of variable "id", and then created a loop that lists all variables that do not match. The last steps I am trying to get to are:

1) Modify the list to group by id (now it list each discrepancy/id on an individual list)
2) Export all of the discrepancies (lists), to one excel file

Below is an example of the merging code, a couple of the variables/format and the final loop that results in the individual lists.

Code:
foreach var of varlist study_complete-covid_complete{
  rename `var' `var'_p1
}

merge 1:1 id using person2
list

input float(v1_ga_p1 v1_ga) int(v1_bd_p1 v1_bd)
12.857142 12.857142 1 1
13.428572 13.428572 1 1
12.714286 12.714286 1 1
11.857142 11.857142 1 1
12.142858 12.142858 1 1
end
label values v1_bd_p1 v1_bd_
label values v1_bd v1_bd_
label def v1_bd_ 1 "1 Yes", modify

forvalues i = 1/93 {
   foreach var of varlist v1_visit_complete-consent_crc{
   list id `var' `var'_p1 if (`var' != `var'_p1) & (v1_complete_p1==2 & v1_complete==2) & _n == `i', abbreviate(15) noobs
   }
}

    +--------------------------------------------------------------------------------------------------------+
     |   id                                                                                  v1_bd   v1_bd_p1 |
     |--------------------------------------------------------------------------------------------------------|
 66. | 0073   999 Not applicable (all that were consented after consent change to V2--insert date)       0 No |
     +--------------------------------------------------------------------------------------------------------+

     +--------------------------------+
     |   id        v1_gel   v1_gel_p1 |
     |--------------------------------|
 66. | 0073   888 Unknown           . |
     +----------------------
Thank you for your time,

Valerie