inner join instead of full outer join

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

inner join instead of full outer join

progster
Hi all, I was wondering how obtain an inner join with the match command, since this returns to me a full outer join.

*full outer join.
DATASET ACTIVATE table_A.
MATCH FILES /FILE=*
  /FILE='table_B'
  /BY id.
EXECUTE.

thanks
Reply | Threaded
Open this post in threaded view
|

Re: inner join instead of full outer join

Andy W
Replace the second FILE subcommand with TABLE, and you get a left join (ie all the records in table_A, with info from table_B where they match on id.)

DATASET ACTIVATE table_A.
MATCH FILES /FILE=*
  /TABLE='table_B'
  /BY id.
EXECUTE.

If you subsequently only want the shared records in both table_A and table_B, use above with the IN subcommand, and then select out cases that were matched.

DATASET ACTIVATE table_A.
MATCH FILES /FILE=*
  /TABLE='table_B'
  /IN Flag_B
  /BY id.
SELECT IF Flag_B = 1.
EXECUTE.

Also the STAR JOIN command might be of interest.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: inner join instead of full outer join

Jignesh Sutar
In reply to this post by progster
data list list / id a.
begin data.
1 84
2 85
3 45 
4 27
5 57
6 82
end data.
dataset name dsT1.
sort cases by ID.

data list list / id b.
begin data.
4 98
5 87
6 54
7 45
8 45
9 45
10 54
end data.
dataset name dsT2.
sort cases by ID.

dataset activate dsT1.
match files file=* /table =dsT2  /in=Source /by id .
select if Source=1.
add files file=* /drop=Source.

On 30 March 2015 at 12:24, progster <[hidden email]> wrote:
Hi all, I was wondering how obtain an inner join with the match command,
since this returns to me a full outer join.

*full outer join.
DATASET ACTIVATE table_A.
MATCH FILES /FILE=*
  /FILE='table_B'
  /BY id.
EXECUTE.

thanks



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/inner-join-instead-of-full-outer-join-tp5729093.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD