= How do I format data for input uto a repeated measures analysis of variance in SPSS? = Part of an example data set is given below representing measures of activity in different regions of the brain specified by eight combinations of areas corresponding to the x, y and z axes (called morph, anterior and lateral respectively) in 3 dimensions. The first four data points for subject 1 are given below. Each subject has replicates of the x, y, z combinations each of which are tried with differing numbers of electrodes. The activities across electrodes are not presumed to differ so we decide to pool them. ||||||||<25% style="TEXT-ALIGN: center"> '''Morph'''||<25% style="TEXT-ALIGN: center"> '''Anterior''' ||<25% style="TEXT-ALIGN: center"> '''Lateral'''||<25% style="TEXT-ALIGN: center"> '''Activity''' || ||||||||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> -0.75 || ||||||||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> -0.03 || ||||||||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> 2 ||<25% style="VERTICAL-ALIGN: top"> 0.85 || ||||||||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> 1 ||<25% style="VERTICAL-ALIGN: top"> 2 ||<25% style="VERTICAL-ALIGN: top"> 0.61 || To present this as repeated measures data in SPSS we need to restructure the data as one row (per subject) with eight columns corresponding to each of the eight regional activity combinations meaned over the electrodes. This can be done by first specifying a combination factor which represents all eight possible combinations of the x,y and z axes. {{{ if (morph eq 1 and anterior eq 1 and lateral eq 1) comb=1. if (morph eq 2 and anterior eq 1 and lateral eq 1) comb=2. if (morph eq 1 and anterior eq 2 and lateral eq 1) comb=3. if (morph eq 1 and anterior eq 1 and lateral eq 2) comb=4. if (morph eq 2 and anterior eq 2 and lateral eq 1) comb=5. if (morph eq 2 and anterior eq 1 and lateral eq 2) comb=6. if (morph eq 1 and anterior eq 2 and lateral eq 2) comb=7. if (morph eq 2 and anterior eq 2 and lateral eq 2) comb=8. exe. }}} We can then use split file with a sort cases commands and the output management system (OMS) to produce a table of brain activity (in variable 'mmna') region combination means for each subject and send these to a SPSS data file. OMS identifies the table of subject by region activity means and reformats the table using the /COLUMNS subcommand before sending it to a file called comb.sav. The reformatted data is then ready for input into a repeated measures anova in SPSS. {{{ SORT CASES BY subj . SPLIT FILE LAYERED BY subj . OMS /SELECT TABLES /IF SUBTYPES=['Report'] /DESTINATION FORMAT=SAV OUTFILE="C:\comb.SAV" /COLUMNS SEQUENCE=[C1 R2]. MEANS TABLES=mmna BY comb /CELLS MEAN COUNT STDDEV. OMSEND. GET FILE ='C:\comb.SAV'. SAVE OUTFILE='C:\comb2.SAV' /DROP=Command_ to Var2 N_1.00 to Std.Deviation_Total /RENAME=(Mean_1.00 to Mean_8.00=M111 M211 M121 M112 M221 M212 M122 M222). exe. GET FILE='C:\comb2.SAV'. }}} For the first two subjects this produces ||||||||||||||||||<11% style="TEXT-ALIGN: center"> ||<11% style="VERTICAL-ALIGN: center"> '''Mean111'''||<11% style="VERTICAL-ALIGN: center"> '''Mean211''' ||<11% style="VERTICAL-ALIGN: center"> '''Mean121'''||<11% style="VERTICAL-ALIGN: center"> '''Mean112''' ||<11% style="VERTICAL-ALIGN: center"> '''Mean221'''||<11% style="VERTICAL-ALIGN: center"> '''Mean212''' ||<11% style="VERTICAL-ALIGN: center"> '''Mean122'''||<11% style="VERTICAL-ALIGN: center"> '''Mean222''' || ||||||||||||||||||<11% style="TEXT-ALIGN: center"> Sub 1 ||<11% style="TEXT-ALIGN: center"> -0.39 ||<11% style="VERTICAL-ALIGN: center"> 0.23 ||<11% style="VERTICAL-ALIGN: center"> -0.42||<11% style="VERTICAL-ALIGN: center"> 0.73 ||<11% style="VERTICAL-ALIGN: center"> 0.24 ||<11% style="VERTICAL-ALIGN: center"> -0.25 ||<11% style="VERTICAL-ALIGN: center"> -0.16||<11% style="VERTICAL-ALIGN: center"> -0.36 || ||||||||||||||||||<11% style="TEXT-ALIGN: center"> Sub 2 ||<11% style="TEXT-ALIGN: center"> -1.22 ||<11% style="VERTICAL-ALIGN: center"> -0.93 ||<11% style="VERTICAL-ALIGN: center"> -0.52||<11% style="VERTICAL-ALIGN: center"> -0.69 ||<11% style="VERTICAL-ALIGN: center"> -0.04 ||<11% style="VERTICAL-ALIGN: center"> 0.05 ||<11% style="VERTICAL-ALIGN: center"> -0.06||<11% style="VERTICAL-ALIGN: center"> -0.76 || The data can now be used in a [[FAQ/glmrm|repeated measures analysis.]] * [[FAQ/btow| Stacking a within subjects factor as a between subjects factor]] * [[FAQ/wtob| Unstacking a between subjects factor to form within subjects factors]].