Matching two data files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Matching two data files

Edward Boadi
Dear List,

I have two data files ,

File1.sav  with variables  Var 1, Var2,Var3  ..... Var8
and
File2.sav  with variable  Var3.

I want to  perform the following task:

Keep all cases in File1.sav  for which Var2 in File1.sav = Var2 in File2.sav.

Any ideas on how to do this task.

Regards to all.
-------Ed
Reply | Threaded
Open this post in threaded view
|

Re: Matching two data files

Richard Ristow
At 02:44 PM 7/18/2006, Edward Boadi wrote:

>File1.sav  with variables  Var 1, Var2,Var3  ..... Var8
>and
>File2.sav  with variable  Var3.
>
>I want to  perform the following task:
>
>Keep all cases in File1.sav  for which Var2 in File1.sav = Var2 in
>File2.sav.

Yes. Not very hard. Except for one caveat, below. And I assume you mean
'var3', above, since File2.sav contains only var3.

First, combine the files. This is not tested, and has BIG CAVEAT.

MATCH FILES
   /FILE=File1.sav/
   /FILE=File2.sav/RENAME=(var3=var3.2).

* CAVEAT: You don't have any shared key between your files, .
* to use a "/BY" subcommand. Matching without a "/BY" is    .
* legal (it's called a "parallel match"), but unwise.       .
* You have no check whatever that matched records correspond.

SELECT IF (var3 EQ var3.2).
* CAVEAT: This will reject any case for which var3 is       .
* missing in either input file.                             .

* You'll have 'var3.2' in the final file. Delete it, if you .
* like.                                                     .
* There's not
Reply | Threaded
Open this post in threaded view
|

Re: Matching two data files

Edward Boadi
In reply to this post by Edward Boadi
Thanks Richard, I am very grateful.

Warm Regards .

-----Original Message-----
From: Richard Ristow [mailto:[hidden email]]
Sent: Tuesday, July 18, 2006 4:01 PM
To: Edward Boadi; [hidden email]
Subject: Re: Matching two data files


At 02:44 PM 7/18/2006, Edward Boadi wrote:

>File1.sav  with variables  Var 1, Var2,Var3  ..... Var8
>and
>File2.sav  with variable  Var3.
>
>I want to  perform the following task:
>
>Keep all cases in File1.sav  for which Var2 in File1.sav = Var2 in
>File2.sav.

Yes. Not very hard. Except for one caveat, below. And I assume you mean
'var3', above, since File2.sav contains only var3.

First, combine the files. This is not tested, and has BIG CAVEAT.

MATCH FILES
   /FILE=File1.sav/
   /FILE=File2.sav/RENAME=(var3=var3.2).

* CAVEAT: You don't have any shared key between your files, .
* to use a "/BY" subcommand. Matching without a "/BY" is    .
* legal (it's called a "parallel match"), but unwise.       .
* You have no check whatever that matched records correspond.

SELECT IF (var3 EQ var3.2).
* CAVEAT: This will reject any case for which var3 is       .
* missing in either input file.                             .

* You'll have 'var3.2' in the final file. Delete it, if you .
* like.                                                     .
* There's not