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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1718 Appendix D<br />

Example 1: Automating a File-Matching Task<br />

Figure D.1 shows a listing of 1988 sales data for salespeople working in different<br />

regions. The listing shows that salesperson Jones sold 900 units in the Chicago sales<br />

territory, while Rodriguez sold 300 units in Baton Rouge.<br />

Figure D.1 Listing of data file SALES88.SAV<br />

YEAR REGION SALESPER SALES<br />

1988 CHICAGO JONES 900<br />

1988 CHICAGO GREGORY 400<br />

1988 BATON ROUGE RODRIGUEZ 300<br />

1988 BATON ROUGE SMITH 333<br />

1988 BATON ROUGE GRAU 100<br />

You can use command syntax shown in Figure D.2 to obtain each salesperson’s percentage<br />

of total sales for their region.<br />

Figure D.2 <strong>Command</strong>s for obtaining sales percentages<br />

GET FILE = ’SALES88.SAV’.<br />

SORT CASES BY REGION.<br />

AGGREGATE OUTFILE = ’TOTALS.SAV’<br />

/PRESORTED<br />

/BREAK = REGION<br />

/TOTAL@ = SUM(SALES).<br />

MATCH FILES FILE=*<br />

/TABLE = ’TOTALS.SAV’<br />

/BY REGION.<br />

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

TITLE 1988 DATA.<br />

LIST.<br />

• The GET command opens SALES88.SAV, an SPSS-format data file. This file<br />

becomes the working data file.<br />

• SORT CASES sorts the working data file in ascending alphabetical order by REGION.<br />

• The AGGREGATE command saves total sales (variable TOTAL@) for each region in<br />

file TOTALS.SAV.<br />

• MATCH FILES appends the regional totals to each salesperson’s record in the working<br />

data file. (See the MATCH FILES command for more information on matching files.)<br />

• COMPUTE obtains the percentage of regional sales (PCT) for each salesperson.

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

Saved successfully!

Ooh no, something went wrong!