Interleaving Cases

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

Interleaving Cases

Matt Freeman
Still in search of assistance on this issue.

I have a list of contractors in a file called X, with variables ID and
Contractor.  For example, two rows in this file might be

100 Turner Construction Company
102 Messer Construction Company

I also have the same list of contractors in a file called Y, with variables
ID_No and Lead.  For example, the corresponding rows in this file might be

101 _Turner Construction Company
103 _Messer Construction Company

I would like to interleave the cases of the two files to appear as

100 Turner Construction Company
101 _Turner Construction Company
102 Messer Construction Company
103 _Messer Construction Company

I've written the following syntax.

GET FILE = "C:Documents and Settings\My Documents\X.sav"
Alter Type Contractor (A80 = A81)
ADD FILES FILE = "C:Documents and Settings\My Documents\Y.sav"
/RENAME = (Lead, ID_No = Contractor, ID)
/FILE = "C:Documents and Settings\My Documents\X.sav"
/BY ID.
OUTFILE = "C:Documents and Settings\My Documents\XY.sav".

I am not obtaining the desired output.  Can anyone help?

Thanks.

=====================
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: Interleaving Cases

Rick Oliver-3
Both files must first be sorted by ID, prior to merging.

data list list (";") /id (f3) contractor (a100).
begin data
100;Turner Construction Company
102;Messer Construction Company
end data.
sort cases by id.
dataset name one.
data list list (";") / id_no (f3) lead (a100).
begin data
101;_Turner Construction Company
103;_Messer Construction Company
end data.
sort cases by id_no.
dataset name two.
add files file=one /file=two /rename (id_no, lead=id, contractor)  /by id.
list.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]
Phone: 312.893.4922 | T/L: 206-4922




From:        Matt Freeman <[hidden email]>
To:        [hidden email]
Date:        07/16/2012 10:17 AM
Subject:        Interleaving Cases
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Still in search of assistance on this issue.

I have a list of contractors in a file called X, with variables ID and
Contractor.  For example, two rows in this file might be

100 Turner Construction Company
102 Messer Construction Company

I also have the same list of contractors in a file called Y, with variables
ID_No and Lead.  For example, the corresponding rows in this file might be

101 _Turner Construction Company
103 _Messer Construction Company

I would like to interleave the cases of the two files to appear as

100 Turner Construction Company
101 _Turner Construction Company
102 Messer Construction Company
103 _Messer Construction Company

I've written the following syntax.

GET FILE = "C:Documents and Settings\My Documents\X.sav"
Alter Type Contractor (A80 = A81)
ADD FILES FILE = "C:Documents and Settings\My Documents\Y.sav"
/RENAME = (Lead, ID_No = Contractor, ID)
/FILE = "C:Documents and Settings\My Documents\X.sav"
/BY ID.
OUTFILE = "C:Documents and Settings\My Documents\XY.sav".

I am not obtaining the desired output.  Can anyone help?

Thanks.

=====================
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: Interleaving Cases

Bruce Weaver
Administrator
In reply to this post by Matt Freeman
Matt, here's your syntax:

GET FILE = "C:Documents and Settings\My Documents\X.sav"
Alter Type Contractor (A80 = A81)
ADD FILES FILE = "C:Documents and Settings\My Documents\Y.sav"
/RENAME = (Lead, ID_No = Contractor, ID)
/FILE = "C:Documents and Settings\My Documents\X.sav"
/BY ID.
OUTFILE = "C:Documents and Settings\My Documents\XY.sav".

And here it is again with some modifications:

GET FILE = "C:\Documents and Settings\My Documents\X.sav".
Alter Type Contractor (A81).
ADD FILES FILE = "C:\Documents and Settings\My Documents\Y.sav"
 /RENAME = (Lead, ID_No = Contractor, ID)
 /FILE = "C:Documents and Settings\My Documents\X.sav"
 /BY ID.
EXECUTE.
SAVE OUTFILE = "C:\Documents and Settings\My Documents\XY.sav".

Note the following differences:

1. Command terminators are missing for most of your commands.
2. ALTER TYPE command -- (A81), not (A80 = A81)
3. C:\Documents and Settings\..., not C:Documents and Settings\...
4. EXECUTE after ADD FILES.

Result of running the modified syntax (after creating two files with your sample cases):

   ID Contractor
 
  100 Turner Construction Company
  101 _Turner Construction Company
  102 Messer Construction Company
  103 _Messer Construction Company
 
Number of cases read:  4    Number of cases listed:  4

HTH.


Matt Freeman wrote
Still in search of assistance on this issue.

I have a list of contractors in a file called X, with variables ID and
Contractor.  For example, two rows in this file might be

100 Turner Construction Company
102 Messer Construction Company

I also have the same list of contractors in a file called Y, with variables
ID_No and Lead.  For example, the corresponding rows in this file might be

101 _Turner Construction Company
103 _Messer Construction Company

I would like to interleave the cases of the two files to appear as

100 Turner Construction Company
101 _Turner Construction Company
102 Messer Construction Company
103 _Messer Construction Company

I've written the following syntax.

GET FILE = "C:Documents and Settings\My Documents\X.sav"
Alter Type Contractor (A80 = A81)
ADD FILES FILE = "C:Documents and Settings\My Documents\Y.sav"
/RENAME = (Lead, ID_No = Contractor, ID)
/FILE = "C:Documents and Settings\My Documents\X.sav"
/BY ID.
OUTFILE = "C:Documents and Settings\My Documents\XY.sav".

I am not obtaining the desired output.  Can anyone help?

Thanks.

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).