Diff for "FAQ/btow" - CBU statistics Wiki
location: Diff for "FAQ/btow"
Differences between revisions 3 and 4
Revision 3 as of 2008-04-28 15:59:44
Size: 939
Editor: PeterWatson
Comment:
Revision 4 as of 2008-04-28 16:01:10
Size: 983
Editor: PeterWatson
Comment:
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 concatennates three within subject level responses (columns) into 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 [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.

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)