Diff for "FAQ/btow" - CBU statistics Wiki
location: Diff for "FAQ/btow"
Differences between revisions 8 and 9
Revision 8 as of 2010-01-26 16:14:34
Size: 983
Editor: PeterWatson
Comment:
Revision 9 as of 2013-03-08 10:17:14
Size: 985
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
Originally taken from [http://www.utexas.edu/faqs/stat/spss/ here] the macro b_to_w.sps stacks a defined number of columns on top of one other (representing within subject level responses) to form one column which can serve as a between subject factor response. Originally taken from [[http://www.utexas.edu/faqs/stat/spss/|here]] the macro b_to_w.sps stacks a defined number of columns on top of one other (representing within subject level responses) to form one column which can serve as a between subject factor response.

Stacking two or more columns into one column

Originally taken from here the macro b_to_w.sps stacks a defined number of columns on top of one other (representing within subject level responses) to form one column which can serve as a between subject factor response.

The between subjects factor is also created in the column called numb. Note: you can also use th restructure command to do this.

DATA LIST FREE
        /idno b1 x b2 b3.
BEGIN DATA
1 3 4 7 1
1 6 5 8 2
1 3 4 7 3
1 3 3 6 8
2 1 2 5 10
2 2 3 6 10
2 2 4 5 9
2 2 3 6 11
END DATA.


define w_to_b (id=!tokens(1)
                      /nvars=!tokens(1)
                      /vars=!cmdend).

VECTOR b=!vars.
LOOP numb=1 TO !nvars.
COMPUTE newb=b(numb).
XSAVE OUTFILE 'C:\test2.sav'
   /KEEP !id numb newb.
END LOOP.
EXE.
GET FILE = 'C:\test2.sav'.
LIST.
!enddefine.

Let's give it a whirl:

w_to_b id=idno nvars=3 vars=b1 to b3.

None: FAQ/btow (last edited 2013-03-08 10:17:14 by localhost)