Search code examples
excelspss

how to merge multiple column data into two columns in SPSS and/or excel?


I am learning data input in SPSS and excel. For example, I have 500 column data format below:

plant1  plant2  plant3  …   plant500
-0.32   -0.01   -0.28   …   …
-0.40   0.14    -0.19   …   …
-0.43   -0.19   -0.29   …   …
-0.48   -0.16   -0.04   …   …

I want to change it to format below:

plant1   -0.32 
plant1   -0.40 
plant1   -0.43 
plant1   -0.48 
plant2   -0.01 
plant2   0.14 
plant2  -0.19 
plant2  -0.16 
plant3  -0.28 
plant3  -0.19 
plant3  -0.29 
plant3  -0.04 
…           …
plant500    …
plant500    …
plant500    …
plant500    …

Can you help me how to do it.

Thanks


Solution

  • In SPSS, assuming your plant1 to plant500 variables are consecutive, the below syntax will do the trick; (if your variables are not consecutive, you will have to specify them one by one).

    VARSTOCASES /MAKE reading from plant1 to plant500 /INDEX=PLANT_NR (reading). EXECUTE.

    Here is more on the VARSTOCASES command: https://www.ibm.com/support/knowledgecenter/en/SSLVMB_23.0.0/spss/base/syn_varstocases_variable_name_index.html