Dear all,
I would like to know if there's a way to compare two case for detecting duplicate case where ID is different.
1.- The existing compare function is for variable, not for record or whole case,
2.- The compare tools is for data file, not for case,
3.- The index file is based on ID.
Please do you have some ideas?
Thanks in advance!
Compare two case
-
htuser
- Posts: 687
- Joined: December 19th, 2011, 6:26 pm
- Location: Silver Spring Area, MD, USA
Compare two case
G.VOLNY, a CSProuser from Haiti, since 2004
-
josh
- Posts: 2403
- Joined: May 5th, 2014, 12:49 pm
- Location: Washington DC
Re: Compare two case
You could write a batch application to do this. You would use one data file as the main data file and the other as an external file. For each case in the main data file you would iterate through all the cases in the external dictionary (using locate and loadcase in a loop) and check if the non id-item variables are the same. The one tricky part here is that you would want to use the same dictionary for both the main data file and the external data file and CSPro will not let you do that. You will have to make a copy of your dictionary and change the name and use the copy for the external file. You may also need to rename some of the items/records/levels to avoid errors about ambiguous symbols.
You might also find it easier to modify the dictionary so that each record has just id-items and a single really long alpha item that is the same length as all the non id-items on that record combined. For example if you have a record like:
MYID length 2
FOO length 2
BAR length 1
BAZ length 4
Then you would change it to:
MYID length 2
MYREC1ITEMS length 7
This way rather than comparing each individual item you can compare the combined items. For example instead of:
if DICT1.FOO = DICT2.FOO and DICT1.BAR = DICT2.BAR and DICT1.BAZ = DICT2.BAZ then
errmsg("This is a duplicate");
endif;
you can do:
if DICT1.MYREC1ITEMS = DICT2.MYREC1ITEMS then
errmsg("This is a duplicate");
endif;
You might also find it easier to modify the dictionary so that each record has just id-items and a single really long alpha item that is the same length as all the non id-items on that record combined. For example if you have a record like:
MYID length 2
FOO length 2
BAR length 1
BAZ length 4
Then you would change it to:
MYID length 2
MYREC1ITEMS length 7
This way rather than comparing each individual item you can compare the combined items. For example instead of:
if DICT1.FOO = DICT2.FOO and DICT1.BAR = DICT2.BAR and DICT1.BAZ = DICT2.BAZ then
errmsg("This is a duplicate");
endif;
you can do:
if DICT1.MYREC1ITEMS = DICT2.MYREC1ITEMS then
errmsg("This is a duplicate");
endif;