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.

252 COMPUTE<br />

String functions:<br />

ANY(arg,arg list) Return 1 if value of argument is included on argument list.<br />

CONCAT(arg list) Join the arguments into a string.<br />

INDEX(a1,a2,a3) Return number indicating position of first occurrence of a2 in a1;<br />

optionally, a2 in a3 evenly divided substrings of a1.<br />

LAG(arg,n) Return value of argument n cases before.<br />

LENGTH(arg) Return length of argument.<br />

LOWER(arg list) Convert upper case to lower case.<br />

LPAD(a1,a2,a3) Left-pad beginning of a1 to length a2 with character a3.<br />

LTRIM(a1,a2) Trim character a2 from beginning of a1.<br />

MAX(arg list) Return maximum value of argument list.<br />

MIN(arg list) Return minimum value of argument list.<br />

NUMBER(arg,format) Convert argument into number using format.<br />

RANGE(arg,arg list) Return 1 if value of argument is in inclusive range of argument list.<br />

RINDEX(a1,a2,a3) Return number indicating rightmost occurrence of a2 in a1;<br />

optionally, a2 in a3 evenly divided substrings of a1.<br />

RPAD(a1,a2,a3) Right-pad end of a1 to length a2 with character a3.<br />

RTRIM(a1,a2) Trim character a2 from end of a1.<br />

STRING(arg,format) Convert argument into string using format.<br />

SUBSTR(a1,a2,a3) Return substring of a1 beginning with position a2 for length a3.<br />

UPCASE(arg list) Convert lower case to upper case.<br />

MBLEN.BYTE(arg,a1) Return the number of bytes for the character beginning at position a1<br />

in the string argument. If a1 is not specified, it defaults to 1.<br />

Example<br />

COMPUTE NEWVAR=RND((V1/V2)*100).<br />

STRING DEPT(A20).<br />

COMPUTE DEPT=’PERSONNEL DEPARTMENT’.<br />

Overview<br />

COMPUTE creates new numeric variables or modifies the values of existing string or numeric<br />

variables. The variable named on the left of the equals sign is the target variable. The variables,<br />

constants, and functions on the right side of the equals sign form an assignment expression.<br />

For a complete discussion of functions, see “Transformation Expressions” on p. 37.<br />

Numeric Transformations<br />

Numeric variables can be created or modified with COMPUTE. The assignment expression<br />

for numeric transformations can include combinations of constants, variables, numeric<br />

operators, and functions.

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

Saved successfully!

Ooh no, something went wrong!