Matching Files

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

Matching Files

Keval Khichadia
example:
data list free/ id gpa.
begin data
1 3.5
2 3.5
3 4.0
end data.
dataset name gpa.
sort cases by id.
data list free/ id status.
begin data
1 12
2 13
3 14
4 15
end data.
dataset name status.
sort cases by id.
match files file = gpa
file = status
/by id.
How can i match the files so the final dataset only reports id and status if the id is in the first file?
Thanks in advance,
Keval


      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Matching Files

Richard Ristow
At 04:59 PM 5/7/2008, Keval Khichadia wrote:

>match files
>    file = gpa
>   /file = status
>   /by id.
>How can i match the files so the final dataset only reports id and
>status if the id is in the first file?

You need to match and then select. If variable "gpa" is never missing
in the 'gpa' dataset, you can use this after your MATCH FILES:

SELECT IF NOT MISSING(gpa).

Or, you can use the /IN subcommand on MATCH FILES:

match files
    file = gpa  /IN=Has_GPA
   /file = status
   /by id.

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |07-MAY-2008 20:52:47       |
|-----------------------------|---------------------------|
       id      gpa   status Has_GPA

     1.00     3.50    12.00    1
     2.00     3.50    13.00    1
     3.00     4.00    14.00    1
     4.00      .      15.00    0

Number of cases read:  4    Number of cases listed:  4


SELECT IF Has_GPA.
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |07-MAY-2008 20:54:44       |
|-----------------------------|---------------------------|
       id      gpa   status Has_GPA

     1.00     3.50    12.00    1
     2.00     3.50    13.00    1
     3.00     4.00    14.00    1

Number of cases read:  3    Number of cases listed:  3
=================================
APPENDIX: Test data
(From original posting - thanks!)
=================================
data list free/ id gpa.
begin data
1 3.5
2 3.5
3 4.0
end data.
dataset name gpa.
sort cases by id.
data list free/ id status.
begin data
1 12
2 13
3 14
4 15
end data.
dataset name status.
sort cases by id.

=====================
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