Below is some data:

Test Day1 Day2 Score
A 1 2 100
B 1 3 62
C 3 4 90
D 2 4 20
E 4 5 80

I am trying to take the values from column 'day' and 'day2' and use them to select the row number for the column score. For example for Test A I would like to find the sum of 100 and 62 because that is the values of the first and second rows of score. Test B I would like to find the sum of 100, 62 and 90.

Is their anyway to do this in the Compute Variable window? Found in the menu Transform-Compute Variable?

I tried the following:

Score(MEAN(VALUE(Day1), VALUE(DAY2)))

This is not the proper way to call the cell location of Score and I received an error. Can anyone help? Thank you!

有帮助吗?

解决方案

You really have two different datasets here. One is a dataset of scores numbered 1 through 5. The other is a dataset that includes indexes into the score dataset. So the steps would be something like this.

First take the scores dataset and transpose it so that it has one row and 5 columns (Data>Transpose)

Then match that dataset to each case in the main dataset (Data>Merge Files>Add Variables). Next you have to resort to using syntax directly. You would declare a vector for the scores (VECTOR) Finally, you use COMPUTE to index into the scores.

For your real problem, I suppose that you might have batches of scores and maybe there are some gaps. The Restructure Data Wizard can help you generalize this - convert cases into variables, but let's not go there yet.

HTH, Jon Peck

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top