How to expand 1 record into multi records.

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

How to expand 1 record into multi records.

Chris-699
Hi Friends,
Please help figure out whether the following operation is feasible in
SPSS. Many thanks!

ID, v1,v2,v3
A1,1,0,1
A2,0,1,1


The result data set will be like:


ID, v1,v2,v3
A1,1,0,0
A1,0,0,1
A2,0,1,0
A2,0,0,1


Regards
Chris

=====================
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: How to expand 1 record into multi records.

Marks, Jim
Chris:

Not tested.

DATASET COPY v1_fix.
DATASET ACTIVATE v1_fix.
SELECT IF v1 = 1.
COMPUTE v2 = 0.
COMPUTE v3 = 0.
EXECUTE.

DATASET ACTIVATE original.
DATASET COPY v2_fix.
DATASET ACTIVATE v2_fix.
SELECT IF v2 = 1.
COMPUTE v1 = 0.
COMPUTE v3 = 0.
EXECUTE.

DATASET ACTIVATE original.
DATASET COPY v3_fix.
DATASET ACTIVATE v3_fix.
SELECT IF v3 = 1.
COMPUTE v1 = 0.
COMPUTE v2 = 0.
EXECUTE.

NEW FILE.
ADD FILES
 /FILE =v1_fix
 /FILE =v2_fix
 /FILE =v3_fix
.
DATASET NAME new_version WINDOW = FRONT.
EXECUTE.

This could get cumbersome if you have more than 3 variables.

--jim

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Chris
Sent: Monday, March 02, 2009 3:50 AM
To: [hidden email]
Subject: How to expand 1 record into multi records.

Hi Friends,
Please help figure out whether the following operation is feasible in
SPSS. Many thanks!

ID, v1,v2,v3
A1,1,0,1
A2,0,1,1


The result data set will be like:


ID, v1,v2,v3
A1,1,0,0
A1,0,0,1
A2,0,1,0
A2,0,0,1


Regards
Chris

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