LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2006)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 18 Apr 2006 11:15:47 -0400
Reply-To:     Richard Ristow <wrristow@mindspring.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Richard Ristow <wrristow@mindspring.com>
Subject:      Re: Nearest Match with Match Files
Comments: To: Brian Moore <bmoore@worldatwork.org>
In-Reply-To:  <6C01A852608309408AD59AFBFF5DD51A2364FF@aca_exchange.worlda
              twork.org>
Content-Type: text/plain; charset=us-ascii; format=flowed;
              x-avg-checked=avg-ok-1029339A

At 02:04 PM 4/17/2006, Brian Moore wrote:

>Is there a way to return a nearest match from a match table? I was >thinking of numerical data and nearest being equal or next highest >number on the lookup table (sorted ascending).

MATCH FILES, directly, can't do it. But it can be done by merging the files with ADD FILES and computing the matching *exact* key for each *approximate* key. See below, which is tested; this is SPSS draft output. ("DATASET ACTIVATE" is SPSS 14 syntax. In earlier versions, one would use scratch .SAV files instead of 'datasets', and they'd be "GET FILE" instead.)

* ............................................... . DATASET ACTIVATE KeyTable. LIST.

List |-----------------------------|---------------------------| |Output Created |18-APR-2006 11:07:51 | |-----------------------------|---------------------------| [KeyTable]

KEY Letter

1 Alpha 2 Beta 3 Gamma 5 Epsilon 6 Eta

Number of cases read: 5 Number of cases listed: 5

DATASET ACTIVATE ToMatch. LIST.

List |-----------------------------|---------------------------| |Output Created |18-APR-2006 11:07:51 | |-----------------------------|---------------------------| [ToMatch]

KEY ANIMAL

.1 Aardvark .2 Anteater 1.0 A. 1.5 Bear 1.7 Borogove 2.0 B. 3.0 C. 3.2 Donkey 3.5 Dromedary 4.0 D. 4.1 Eel 4.6 Elephant 5.0 E.

Number of cases read: 13 Number of cases listed: 13

ADD FILES /FILE = KeyTable /RENAME=(KEY=RoughKey)/IN=Key_Recd /FILE = * /RENAME=(KEY=RoughKey) /BY RoughKey. FORMATS RoughKey (F4.1)

* "nearest being equal or next highest number" requires . * descending order .

RECODE Key_Recd (1=1)(ELSE=0). SORT CASES BY RoughKey Key_Recd (D).

* Compute the corresponding exact-match key for each . * approximate key .

NUMERIC KEY (F2). LEAVE KEY. IF (Key_Recd EQ 1) KEY=RoughKey. SELECT IF Key_Recd EQ 0. SORT CASES By RoughKey.

LIST KEY RoughKey Animal.

List |-----------------------------|---------------------------| |Output Created |18-APR-2006 11:07:52 | |-----------------------------|---------------------------| [ToMatch]

KEY RoughKey ANIMAL

1 .1 Aardvark 1 .2 Anteater 1 1.0 A. 2 1.5 Bear 2 1.7 Borogove 2 2.0 B. 3 3.0 C. 5 3.2 Donkey 5 3.5 Dromedary 5 4.0 D. 5 4.1 Eel 5 4.6 Elephant 5 5.0 E.

Number of cases read: 13 Number of cases listed: 13

* Now, match, using the computed exact key .

MATCH FILES /TABLE= KeyTable /FILE = * /BY Key /KEEP = Key RoughKey Letter Animal. LIST.

List |-----------------------------|---------------------------| |Output Created |18-APR-2006 11:07:52 | |-----------------------------|---------------------------| [ToMatch]

KEY RoughKey Letter ANIMAL

1 .1 Alpha Aardvark 1 .2 Alpha Anteater 1 1.0 Alpha A. 2 1.5 Beta Bear 2 1.7 Beta Borogove 2 2.0 Beta B. 3 3.0 Gamma C. 5 3.2 Epsilon Donkey 5 3.5 Epsilon Dromedary 5 4.0 Epsilon D. 5 4.1 Epsilon Eel 5 4.6 Epsilon Elephant 5 5.0 Epsilon E.

Number of cases read: 13 Number of cases listed: 13

-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.385 / Virus Database: 268.4.2/314 - Release Date: 4/16/2006


Back to: Top of message | Previous page | Main SPSSX-L page