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.

500 DO IF<br />

Example<br />

INPUT PROGRAM.<br />

DATA LIST FILE=CARPARTS /PARTNO 1-2 KIND 10-14 (A).<br />

DO IF (PARTNO EQ 11 AND KIND EQ ’FORD’).<br />

+ REREAD.<br />

+ DATA LIST /PRICE 3-6 (2) QUANTITY 7-9 BUYER 20-43 (A).<br />

+ END CASE.<br />

ELSE IF (PARTNO EQ 11 AND (KIND EQ ’CHEVY’ OR KIND EQ ’VW’)).<br />

+ REREAD.<br />

+ DATA LIST /PRICE 15-18 (2) QUANTITY 19-21 BUYER 30-53 (A).<br />

+ END CASE.<br />

END IF.<br />

END INPUT PROGRAM.<br />

PRINT FORMATS PRICE (DOLLAR6.2).<br />

PRINT /PARTNO TO BUYER.<br />

WEIGHT BY QUANTITY.<br />

DESCRIPTIVES PRICE.<br />

• The first DATA LIST extracts the part number and the type of automobile.<br />

• Depending on the information from the first DATA LIST, the records are reread, pulling the<br />

price, quantity, and buyer from different places.<br />

• The two END CASE commands limit the working file to only those cases with Part 11 and<br />

automobile type Ford, Chevrolet, or Volkswagen. Without the END CASE commands,<br />

cases would be created in the working file for other part numbers and automobile types<br />

with missing values for price, quantity, and buyer.<br />

• The results of the PRINT command are shown in Figure 1.<br />

Figure 1 Printed information for part 11<br />

11 FORD $12.95 100 CHAPMAN AUTO SALES<br />

11 FORD $3.95 25 BETTER USED CARS<br />

11 CHEVY $1.95 5 HUFFMAN SALES & SERVICE<br />

11 VW $5.95 20 MIDWEST VOLKSWAGEN SALES<br />

11 CHEVY $2.95 15 SAM’S AUTO REPAIR

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

Saved successfully!

Ooh no, something went wrong!