Data manipulation in SPSS

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

Data manipulation in SPSS

sarah-2
Hello all,

Hopefully this question has an easy solution... but I just can't seem to
find how to do this.

I have 1 variable that contains 10 numbers, and each position can range
from 0 to 3. An example would be....

0113201201

Is there an SPSS function that can separate each position into its own
variable (somewhat similar to the 'text to columns' function in Excel)?

My goal would be to have 10 separate variables, keeping with the example
above, as:

0  1  1  3  2  0  1  2  0  1


Thanks so much, in advance!

Sarah

=====================
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: Data manipulation in SPSS

John F Hall
You could try copying a block of data to a word file, but this might not get
the format you need.

What you probably need to do is use a crafty trick with COMPUTE mixed with
TRUNC and MOD functions.  Quite complex to do at a minute's notice, and
completely untested, but your first variable is:

COMPUTE V1 = trunc (myvar / 1000000000 ) .

. . .followed by:

Compute v2 = trunc (myvar / 100000000 - V1 ) .
Compute v3 = trunk (myvar / 10000000 - V1 - V2 ) .

...and so on.

Someone on the list will surely come up with something neater, but try this
for now.


John Hall
[hidden email]
www.surveyresearch.weebly.com





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Sarah
Sent: 18 April 2011 18:35
To: [hidden email]
Subject: Data manipulation in SPSS

Hello all,

Hopefully this question has an easy solution... but I just can't seem to
find how to do this.

I have 1 variable that contains 10 numbers, and each position can range
from 0 to 3. An example would be....

0113201201

Is there an SPSS function that can separate each position into its own
variable (somewhat similar to the 'text to columns' function in Excel)?

My goal would be to have 10 separate variables, keeping with the example
above, as:

0  1  1  3  2  0  1  2  0  1


Thanks so much, in advance!

Sarah

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

Re: Data manipulation in SPSS

Tesiny, Ed
In reply to this post by sarah-2
Sarah,
If the original variable is a string, you could use the SUBSTR function
in a compute statement. SUBSTR(a1,a2,a3)
A1 - Original string name
A2 - begin position
A3 - length

Ed Tesiny
[hidden email]

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Sarah
Sent: Monday, April 18, 2011 12:35 PM
To: [hidden email]
Subject: Data manipulation in SPSS

Hello all,

Hopefully this question has an easy solution... but I just can't seem to
find how to do this.

I have 1 variable that contains 10 numbers, and each position can range
from 0 to 3. An example would be....

0113201201

Is there an SPSS function that can separate each position into its own
variable (somewhat similar to the 'text to columns' function in Excel)?

My goal would be to have 10 separate variables, keeping with the example
above, as:

0  1  1  3  2  0  1  2  0  1


Thanks so much, in advance!

Sarah

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

Re: Data manipulation in SPSS

Albert-Jan Roskam
In reply to this post by sarah-2
hello,

do repeat #v = v1 to v10  / #n = 1 to 10.
+compute #v = number(substr(yourVar, 1, #n), f1).
end repeat.
 
Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



From: Sarah <[hidden email]>
To: [hidden email]
Sent: Mon, April 18, 2011 6:34:33 PM
Subject: [SPSSX-L] Data manipulation in SPSS

Hello all,

Hopefully this question has an easy solution... but I just can't seem to
find how to do this.

I have 1 variable that contains 10 numbers, and each position can range
from 0 to 3. An example would be....

0113201201

Is there an SPSS function that can separate each position into its own
variable (somewhat similar to the 'text to columns' function in Excel)?

My goal would be to have 10 separate variables, keeping with the example
above, as:

0  1  1  3  2  0  1  2  0  1


Thanks so much, in advance!

Sarah

=====================
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: Data manipulation in SPSS

starraf
In reply to this post by sarah-2
This syntax worked perfectly, thanks so much Albert- and to everyone else for your suggestions!

Sarah