Stack Columns

Data > Variable > More > Stack

 

Use Stack Columns to move data from two or more columns to one longer column within your current datasheet or to a new datasheet.

When you stack columns, you can also create a column of groups, or identifier codes, that indicate which column an observation came from. You can use these labels to:

subset your data

create graphs in which data points display differently depending on which group they are from

unstack the columns

 

In the illustration below, 5 varieties of peas are tested by cooperatives to determine which is best suited for production. A field was divided into 20 plots, with each variety of peas planted in four plots. The data in the B column are stacked below the data in the A column and on top of the data in the C column in the new Group Column. The data in columns D and E are at the last position.

 

Variety of Pea

A

B

C

D

E

26.2

29.2

29.1

21.3

20.1

24.3

28.1

30.8

22.4

19.3

21.8

27.3

33.9

24.3

19.9

28.1

31.2

32.8

21.8

22.1

                                    arrow_down

Variety of Pea

Value

Group Column

26.2

A

24.3

A

21.8

A

28.1

A

29.2

B

28.1

B

27.3

B

31.2

B

29.1

C

30.8

C

33.9

C

32.8

C

21.3

D

22.4

D

24.3

D

21.8

D

20.1

E

19.3

E

19.9

E

22.1

E

 

The values in the Group-Column are labels that identify which column the value came from.

It is usually a good idea to store a subscript column so you can identify the data point associated with each group. For example, in this case, you could analyze the data in Value, using the data in Group-Column as a factor or a grouping variable.

 

Dialog box items

Variable to Stack:
Choose the columns you want to stack. The first is stacked on top of the second, the second on top of the third, and so on.
To select nonconsecutive columns, press and hold down CTRL, and then click each item.
You can select many columns. Use the Ctrl key to select (or unselect) distant columns.

Sheet Name:
Specify a name for the datasheet. This may be a new datasheet or the name of an existing datasheet. Leave blank to store data in a new datasheet.

Stacked Data:
Choose the location (column name) for the stacked data. You can choose to store the stacked data in a column of an existing datasheet and specify that column. Leave blank to create a new column.

Group Column:
Enter a column where you want to store labels. Leave blank to create a new column.
The group column will contain the column name of the successive stacked data. This group column may be used for factor levels in analysis of variance procedures or as a grouping variable for other descriptive and investigatory procedures. It may also be used to unstack a column at a later time.

 

Data

Data can be numeric, text, or any type of data.

Columns are not required to be the same length.

 

Example

Suppose we measure the thickness of plaque (mm) in the carotid artery of 10 randomly selected patients with mild atherosclerotic disease. Two measurements are taken, thickness before treatment with Vitamin E (baseline) and after two years of taking Vitamin E daily.

1.Open the DataBook compare.vstz

2.Select the sheet plaque

3.Choose the tab Data, the group Variable and the command Stack

4.In Variable to Stack, select Before and After.

5.In Stacked Data, enter Measure.

6.In Group Variable, enter Thickness.

7.Click OK

 

 

DataSheet window output

 

Measure

Thickness

0.6600

Before

0.7200

Before

0.8500

Before

0.6200

Before

0.5900

Before

0.6300

Before

0.6400

Before

0.7000

Before

0.7300

Before

0.6800

Before

0.6000

After

0.6500

After

0.7900

After

0.6300

After

0.5400

After

0.5500

After

0.6200

After

0.6700

After

0.6800

After

0.6400

After