# How to "stack" variables

#### Eaners

##### New Member
Say that I have performed a survey in which I have asked subjects to use a three-item, five-point Likert scale to rate three scenarios. My data would be formatted to look something like this (Sx indicates scenario, Ix indicates item):

Code:
Subject S1_I1 S1_I2 S1_I3 S2_I1 S2_I2 S2_I3 S3_I1 S3_I2 S3_I3
1      5     2     3     3     4     1     2     1     1
2      3     5     2     4     1     2     1     5     2
3      4     4     1     1     2     1     4     3     1
etc.   ...
Now let's say that for the purposes of my analysis I need to "line up" all of my similar items and disregard the specific scenarios to look more like this:

Code:
 Subject S1_I1-3 S2_I1-3 S3_I1-3
1       5       3       2
1       2       4       1
1       3       1       1
2       3       4       1
2       5       1       5
2       2       2       2
3       4       1       4
3       4       2       3
3       1       1       1
etc.    ...
First of all, does this kind of transformation have a name? Second, how do I do it in SPSS? Help is greatly appreciated!

#### Eaners

##### New Member
As it may be useful, I am using SPSS on a Mac, v22. I think what I need to do is "merge variables," but I'm unsure how.

#### helicon

##### Member
It is commonly called either restructure or reshape - where data is converted from wide format to long format or vice versa. In SPSS this is achieved using the VARSTOCASES command for wide to long (what you want here) or CASESTOVARS for long to wide.

The syntax for your particular example would be:

Code:
VARSTOCASES
/MAKE scenario1 FROM S1_I1 S1_I2 S1_I3
/MAKE scenario2 FROM S2_I1 S2_I2 S2_I3
/MAKE scenario3 FROM S3_I1 S3_I2 S3_I3
/INDEX=Index1(3)
/KEEP=Subject
/NULL=KEEP.

#### Eaners

##### New Member
That seems straightforward enough. Thank you, I'll give it a try!