27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1722 Appendix D<br />

Figure D.7 Listing of file SCHOOL.SAV<br />

CLASS STUDENT ABSENT<br />

101 BARRY G 3<br />

101 JENNI W 1<br />

101 ED F 2<br />

101 JOHN 0 8<br />

102 PAUL Y 2<br />

102 AMY G 3<br />

102 JOHN D 12<br />

102 RICH H 4<br />

The !TOTMAC macro in Figure D.8 can produce a variety of group summary statistics<br />

such as sum, mean, and standard deviation for any SPSS-format data file. In the macro<br />

call you specify values of keyword arguments indicating the data file (FILE), the break<br />

(grouping) variable (BREAKVR), the summary function (FUNC), and the variable to be<br />

used as input to the summary function (INVAR). For example, to obtain mean absences<br />

for each classroom, we specify SCHOOL.SAV as the data file, CLASS as the break variable,<br />

MEAN as the summary function, and ABSENT as the variable whose values are to<br />

be averaged.<br />

Figure D.8 !TOTMAC macro with keyword arguments<br />

DEFINE !TOTMAC ( BREAKVR = !TOKENS(1)<br />

/FUNC = !TOKENS(1)<br />

/INVAR = !TOKENS(1)<br />

/TEMP = !TOKENS(1) !DEFAULT(TOTALS.SAV)<br />

/FILE = !CMDEND).<br />

GET FILE = !FILE.<br />

SORT CASES BY !BREAKVR.<br />

AGGREGATE OUTFILE = ’!TEMP’<br />

/PRESORTED<br />

/BREAK = !BREAKVR<br />

/!CONCAT(!FUNC,’@’) = !FUNC(!INVAR).<br />

MATCH FILES FILE = *<br />

/TABLE = ’!TEMP’<br />

/BY !BREAKVR.<br />

!ENDDEFINE.<br />

!TOTMAC BREAKVR=CLASS FUNC=MEAN INVAR=ABSENT FILE=SCHOOL.SAV.<br />

COMPUTE DIFF = ABSENT-MEAN@.<br />

LIST.<br />

!TOTMAC BREAKVR=REGION FUNC=SUM INVAR=SALES FILE=SALES89.SAV.<br />

COMPUTE PCT = 100 * SALES / SUM@.<br />

LIST.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!