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 (July 2007)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 12 Jul 2007 05:53:45 -0700
Reply-To:     Ucal Gyam <ucalgyam@yahoo.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Ucal Gyam <ucalgyam@yahoo.com>
Subject:      Re: Combining Two Datafiles
Comments: To: Richard Ristow <wrristow@mindspring.com>
Content-Type: text/plain; charset=ascii

Thanks for your response Richard . You are right , if records match (on those three variables) in both files, I want to keep both (all) records in my output file, not merge them into one.

Which part of syntax wont give me desired results if there both files have the same variables?

----- Original Message ---- From: Richard Ristow <wrristow@mindspring.com> To: SPSSX-L@LISTSERV.UGA.EDU Sent: Wednesday, July 11, 2007 11:55:02 PM Subject: Re: Combining Two Datafiles

At 01:59 PM 7/11/2007, Ucal Gyam wrote:

>I have 2 datafiles FileA and FileB with same variables, I want to >Create a third datafile FileC containing only records from both FileA >and FileB Where the values of the variables x1 , x2 and x3 (ie same >matching records on x1,x2 and x3) in both datafiles are equal .

If I read you correctly: if records match (on those three variables) in both files, you want to keep both records in your output file, not merge them into one. (The latter won't give the desired results anyway, if there both files have the same variables.)

The following is not tested. It assumes that FileA, FileB, FileC are valid file references, perhaps file handles. It uses datasets (SPSS 14 and beyond). If you have an earlier SPSS, you can make srtFileB a scratch .SAV file, changing the dataset-handling logic to file-handling logic.

This logic leaves variables FrmFileA, FrmFileB, InFileA and InFileB in the output file. I think you should keep the first two of these. If you don't want the others, add /DROP InFileA InFileB to your SAVE statement.

GET FILE=FileB. SORT CASES BY x1 x2 x3. DATASET NAME srtFileB.

GET FILE=FileA. SORT CASES BY x1 x2 x3.

ADD FILES /FILE=* /IN=FrmFileA /FILE=srtFileB /IN=FrmFileB /BY x1 x2 x3.

AGGREGATE OUTFILE=* MODE=ADDVARIABLES /BREAK = x1 x2 x3 /InFileA 'x1-x2-x3 key found in FileA' = MAX(FrmFileA) /InFileB 'x1-x2-x3 key found in FileB' = MAX(FrmFileB).

SELECT IF FrmFileA EQ 1 AND FrmFileB EQ 1.

SAVE OUTFILE=FileC.

____________________________________________________________________________________ Pinpoint customers who are looking for what you sell. http://searchmarketing.yahoo.com/


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