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.

1482 SELECT IF<br />

Example<br />

Example<br />

Example<br />

SELECT IF ((V1-15) LE (V2*(-0.001))).<br />

• The logical expression compares whether V1 minus 15 is less than or equal to V2 multiplied<br />

by −0.001. If it is, the case is selected.<br />

SELECT IF ((YRMODA(88,13,0) - YRMODA(YVAR,MVAR,DVAR)) LE 30).<br />

• The logical expression subtracts the number of days representing the date (YVAR, MVAR,<br />

and DVAR) from the number of days representing the last day in 1988. If the difference is<br />

less than or equal to 30, the case is selected.<br />

* Creating a sequence number.<br />

COMPUTE #CASESEQ=#CASESEQ+1.<br />

SELECT IF (MOD(#CASESEQ,2)=0).<br />

• This example computes a scratch variable, #CASESEQ, containing the sequence numbers<br />

for each case. Every other case beginning with the second is selected.<br />

• #CASESEQ must be a scratch variable so that it is not reinitialized for every case. An alternative<br />

is to use the LEAVE command.<br />

Example<br />

DO IF SEX EQ ’M’.<br />

+ SELECT IF PRESTIGE GT 50.<br />

ELSE IF SEX EQ ’F’.<br />

+ SELECT IF PRESTIGE GT 45.<br />

END IF.<br />

• The SELECT IF commands within the DO IF structure select males with prestige scores<br />

above 50 and females with prestige scores above 45.

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

Saved successfully!

Ooh no, something went wrong!