Data Transformation - Horizontal to Verticle

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

Data Transformation - Horizontal to Verticle

Analyst Artist
Hi All,

I would like to know how to transform a dataset that is structured
horizontally to vertically indexed by a serial number.  As such, the
vertical structure would have repeating serial number.

For instance, the horizontal structure is like this:

Serial, Field1, Field2
1, aaa, bbb
2, 123, 321
3, 1a1, 2b2

Need to convert the above into vertical structure like this:

Serial, Datavalue
1, aaa
1, bbb
2, 123
2, 321
3, 1a1
3, 2b2

Any insights into this?  I know that SPSS has a quick data transformation
from horizontal to vertical but it does not take the index into consideration.

Thanks you kindly.

=====================
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 Transformation - Horizontal to Verticle

Daniel Robertson
Use VARSTOCASES, e.g., for your data, something like this...

VARSTOCASES
  /MAKE Datavalue FROM Field1 Field2
  /KEEP = Serial.

Also available via menus at Data -> Restructure. The syntax guide
documents additional syntax options.

Analyst Artist wrote:

> Hi All,
>
> I would like to know how to transform a dataset that is structured
> horizontally to vertically indexed by a serial number.  As such, the
> vertical structure would have repeating serial number.
>
> For instance, the horizontal structure is like this:
>
> Serial, Field1, Field2
> 1, aaa, bbb
> 2, 123, 321
> 3, 1a1, 2b2
>
> Need to convert the above into vertical structure like this:
>
> Serial, Datavalue
> 1, aaa
> 1, bbb
> 2, 123
> 2, 321
> 3, 1a1
> 3, 2b2
>
> Any insights into this?  I know that SPSS has a quick data transformation
> from horizontal to vertical but it does not take the index into consideration.
>
> Thanks you kindly.
>
> =====================
> 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 / 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