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.

Using the Macro Facility 1721<br />

• In each iteration of the loop, the GET command opens an SPSS-format data file. The<br />

name of the file is constructed using the string manipulation function !CONCAT,<br />

which creates a string that is the concatenation of SALES, the value of the index variable,<br />

and .SAV. Thus the file SALES88.SAV is opened in the first iteration.<br />

• <strong>Command</strong>s between AGGREGATE and COMPUTE calculate percentages on the<br />

working data file. These commands are identical to those in Figure D.4.<br />

• Next, a customized title is created. In the first iteration, the direct assignment<br />

command !LET assigns a value of 1988 to the macro variable !YEAR. This variable is<br />

used in the TITLE command on the following line to specify a title of 1988 DATA.<br />

• The LIST command displays the contents of each variable.<br />

• In the second iteration of the loop, commands display percentages for the 1989 data<br />

file. The output from the !TOTMAC macro is shown in Figure D.6. Note that the listing<br />

for 1988 data is the same as in Figure D.3.<br />

Figure D.6 Regional sales percentages for 1988 and 1989<br />

1988 DATA<br />

YEAR REGION SALESPER SALES TOTAL@ PCT<br />

1988 BATON ROUGE RODRIGUEZ 300 733.00 41.00<br />

1988 BATON ROUGE SMITH 333 733.00 45.00<br />

1988 BATON ROUGE GRAU 100 733.00 14.00<br />

1988 CHICAGO JONES 900 1300.00 69.00<br />

1988 CHICAGO GREGORY 400 1300.00 31.00<br />

1989 DATA<br />

YEAR REGION SALESPER SALES TOTAL@ PCT<br />

1989 BATON ROUGE GRAU 320 1459.00 22.00<br />

1989 BATON ROUGE SMITH 800 1459.00 55.00<br />

1989 BATON ROUGE RODRIGUEZ 339 1459.00 23.00<br />

1989 CHICAGO JONES 300 1439.00 21.00<br />

1989 CHICAGO STEEL 899 1439.00 62.00<br />

1989 CHICAGO GREGORY 240 1439.00 17.00<br />

Let’s look at another application of the !TOTMAC macro, one that uses keyword arguments<br />

to make the application more flexible. Figure D.7 shows the number of absences for students<br />

in two classrooms. Let’s say you want to calculate deviation scores indicating how many<br />

more (or fewer) times a student was absent than the average student in his or her classroom.<br />

The first step in obtaining deviation scores is to compute the average number of absences per<br />

classroom. We can use the !TOTMAC macro to compute classroom means by modifying the<br />

macro so that it computes means and uses the absences data file (SCHOOL.SAV) as input.

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

Saved successfully!

Ooh no, something went wrong!