Re: Data Format in SPSS by Syntax?

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

Re: Data Format in SPSS by Syntax?

Hans Chen
Dear Sir /Madam:
========================================
I have following type of data set as follows:

obs x1    x2   x3 x4 x5 x6 x7 x8 x9 x10
1
2
.
.
.
5000
==========================================
Could you show me how to transform into following data fomat? Thanks for
your advice in advance!
===================================
obs
1 x1
1 x2
1 x3
2 x1
2 x2
2 x3
3 x1
3 x2
3 x3
4 x1
4 x2
4 x3
5
.
.
.
==================================

=====================
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 Format in SPSS by Syntax?

Daniel Robertson
If I understand your request, you're trying to restructure your file
from a wide to a long format. If so, try this syntax:
VARSTOCASES
 /MAKE var FROM x1 x2 x3 x4 x5 x6 x7 x8 x9 x10
 /INDEX = varName(var)
 /KEEP =  obs.

Now each each observation is represented by 10 rows, one for each
variable. 'obs' identifies the observation, 'varName' identifies the
variable name, and 'var' contains the value of the variable for that
observation.

hope this helps,
Dan R.

SPSS Chen wrote:

> Dear Sir /Madam:
> ========================================
> I have following type of data set as follows:
>
> obs x1    x2   x3 x4 x5 x6 x7 x8 x9 x10
> 1
> 2
> .
> .
> .
> 5000
> ==========================================
> Could you show me how to transform into following data fomat? Thanks for
> your advice in advance!
> ===================================
> obs
> 1 x1
> 1 x2
> 1 x3
> 2 x1
> 2 x2
> 2 x3
> 3 x1
> 3 x2
> 3 x3
> 4 x1
> 4 x2
> 4 x3
> 5
> .
> .
> .
> ==================================
>
> =====================
> 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
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University, Ithaca NY 14853-2801
607.255.9642 / irp.cornell.edu

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