Match one to many where key has 4 variables
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | * My data sets contain data from an archaeological site and the first four variables in both tables tell the location of an artifact in a site. The first table is the artifact table and has data on 23,000 artifacts with several artifacts coming from each location and listed seperatly. (there can be as many as 50 entries that all share the same first four variables and same location). The second table is the context data and contains 1,600 entries in this table there is only one entry for each artifact location. I wish to merge these tables so that the correct location information will be coppied into the first table. * (A) Answer (sent by email) by Raynald Levesque 2003/01/24. DATA LIST LIST /v1 v2 v3 v4 (4A2). BEGIN DATA 1 a 1 1 1 a 2 1 1 a 2 1 1 b 1 2 a 2 2 2 c 2 END DATA. SORT CASES BY v1 TO v4. SAVE OUTFILE='c:\\temp\\table1.sav'. DATA LIST FIXED /v1 1-2(A) v2 4-5(A) v3 7-8(A) v4 10-11(A) locinfo 13-30(A). BEGIN DATA 1 a 1 1 loc info 1a11 1 a 2 1 loc info 1a21 1 b 1 loc info 1b1 2 a 2 2 loc info 2a22 2 c 2 loc info 2c2 END DATA. SORT CASES BY v1 TO v4. SAVE OUTFILE='c:\\temp\\table2.sav'. *** Start job. MATCH FILES FILE='c:\\temp\\table1.sav' /TABLE='c:\\temp\\table2.sav' /BY=v1 v2 v3 v4. EXECUTE. |
Related pages
...