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.

Appendix D<br />

Using the Macro Facility<br />

A macro is a set of commands that generates customized command syntax. Using<br />

macros can reduce the time and effort needed to perform complex and repetitive data<br />

analysis tasks.<br />

Macros have two parts: a macro definition, which indicates the beginning and end<br />

of the macro and gives a name to the macro, and a macro body, which contains regular<br />

commands or macro commands that build command syntax. When a macro is invoked<br />

by the macro call, syntax is generated in a process called macro expansion. Then the<br />

generated syntax is executed as part of the normal command sequence.<br />

This chapter shows how to construct macros that perform three data analysis tasks. In<br />

the first example, macros facilitate a file-matching task. In Example 2, macros automate<br />

a specialized statistical operation (testing a sample correlation coefficient against a nonzero<br />

population correlation coefficient). Macros in Example 3 generate random data. As<br />

shown in Table D.1, each example demonstrates various features of the macro facility.<br />

For information on specific macro commands, see the DEFINE command.<br />

Table D.1 Macro features<br />

Example 1 Example 2 Example 3<br />

Macro argument<br />

Keyword x x x<br />

Default values x x<br />

None x x<br />

String manipulation x<br />

Looping<br />

x<br />

Index x x<br />

List processing x<br />

Direct assignment x x<br />

1717

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

Saved successfully!

Ooh no, something went wrong!