0% found this document useful (0 votes)
9 views15 pages

Spss Functions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views15 pages

Spss Functions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

USING SPSS FUNCTIONS FOR MAKING

AND RECODING VARIABLES | SPSS


LEARNING MODULES
1. Introduction
SPSS has a wide variety of functions you can use for creating and recoding variables. We will explore three kinds of
functions: mathematical functions, string functions, and random number functions. These functions have the same general
syntax:

function_name(argument1, argument2, etc.)

We will illustrate some functions using the following data file that includes name, x, test1, test2, and test3.

DATA LIST FREE /


name (A14) x test1 test2 test3.
BEGIN DATA.
"John Smith" 4.2 86.5 84.55 81
"Samuel Adams" 9.0 -99 82.37 -99
"Ben Johnson" -6.2 82.1 84.81 87
"Chris Adraktas" 9.5 94.2 -99 93
"John Brown" -999 79.7 79.07 72
END DATA.

LIST.

The output of the LIST command is shown below.

NAME X TEST1 TEST2 TEST3

John Smith 4.20 86.50 84.55 81.00


Samuel Adams 9.00 -99.00 82.37 -99.00
Ben Johnson -6.20 82.10 84.81 87.00
Chris Adraktas 9.50 94.20 -99.00 93.00
John Brown -999.00 79.70 79.07 72.00

The variable x uses -999 to indicate missing values, and test1, test2 and test3 use -99 to indicate missing values. Below
we tell SPSS about these missing values and list out the data again.

MISSING VALUES x (-999)


/test1 test2 test3 (-99).

LIST.

The output is shown below. Note that the data really does not look any different after we have defined the missing values.
But, as we will see below, SPSS does know to treat these values as missing rather than treating them as though they were -
99 and -999.

NAME X TEST1 TEST2 TEST3

John Smith 4.20 86.50 84.55 81.00


Samuel Adams 9.00 -99.00 82.37 -99.00
Ben Johnson -6.20 82.10 84.81 87.00
Chris Adraktas 9.50 94.20 -99.00 93.00
John Brown -999.00 79.70 79.07 72.00

2. Math functions
Now let’s try some basic math functions. The trunc function (short for truncate) takes a number and converts it to a whole
number (integer) by removing all the decimal places, for example, 6.99 and 6.49 would become 6. By contrast,
the rnd function (short for round) rounds numbers to the nearest whole number using conventional rounding rules, for
example 6.99 would become 7, but 6.49 would become 6.

COMPUTE t1tr = TRUNC(test1).


COMPUTE t2tr = TRUNC(test2).

COMPUTE t1rnd = RND(test1).


COMPUTE t2rnd = RND(test2).

LIST name test1 t1tr t1rnd test2 t2tr t2rnd.

The results below are as we would expect.

NAME TEST1 T1TR T1RND TEST2 T2TR T2RND

John Smith 86.50 86.00 87.00 84.55 84.00 85.00


Samuel Adams -99.00 . . 82.37 82.00 82.00
Ben Johnson 82.10 82.00 82.00 84.81 84.00 85.00
Chris Adraktas 94.20 94.00 94.00 -99.00 . .
John Brown 79.70 79.00 80.00 79.07 79.00 79.00

SPSS has other mathematical functions. Below we illustrate functions for getting the square root (sqrt), natural log (ln), log
to the base 10 (lg10) and exponential (exp). Note that the sqrt, ln and lg10 functions do not work with negative numbers
(for example you cannot take the square root of a negative number). SPSS will generate missing values in such cases, as
we will see below.

COMPUTE xsqrt = SQRT(x).


COMPUTE xln = LN(x).
COMPUTE xlg10 = LG10(x).
COMPUTE xexp = EXP(x).
EXECUTE.

LIST x xsqrt xln xlg10 xexp.

The results are shown below. We expected SPSS to generate missing values for xsqrt, xln and xlg10 when x was negative
and we see below that those values are displayed as a single decimal point. This is the way that SPSS shows a system
missing value. Also, we see that xsqrt, xln, xlg10 and xexp were all assigned system missing values when x was -999.

X XSQRT XLN XLG10 XEXP

4.20 2.05 1.44 .62 66.69


9.00 3.00 2.20 .95 8103.08
-6.20 . . . .00
9.50 3.08 2.25 .98 13359.73
-999.00 . . . .

The results also included warnings like the one shown below. The one below is telling us that you cannot take the square
root of a negative number and that SPSS is going to set the result to the system missing value.
Warning # 603
The argument to the square root function is less than zero. The result has
been set to the system-missing value.

3. Statistical functions
SPSS also has statistical functions that operate on one or more variables. For example, we might want to compute the
average of the three test scores. SPSS has the MEAN function that can do that for you, as shown below.

COMPUTE avg = MEAN(test1, test2, test3).


LIST name test1 test2 test3 avg.

We see the results below. Note that SPSS computed the mean of the non missing values. For Samuel Adams, that meant
that his average was the same as his score on test2 since that was the only non-missing value. We could tell SPSS to give
anyone a missing value if they have fewer than 2 valid test scores using the mean.2 function. Likewise, we could tell SPSS
that we want the mean to be missing if any of the scores were missing, by using the mean.3 function. These are illustrated
below.

COMPUTE avg2 = MEAN.2(test1, test2, test3).


COMPUTE avg3 = MEAN.3(test1, test2, test3).
LIST name test1 test2 test3 avg avg2 avg3.

As you see below, avg2 is missing for Samuel Adams, and avg3 is also missing for Samuel Adams and Chris Adraktas
because they both had some missing test scores.

NAME TEST1 TEST2 TEST3 AVG AVG2 AVG3


John Smith 86.50 84.55 81.00 84.02 84.02 84.02
Samuel Adams -99.00 82.37 -99.00 82.37 . .
Ben Johnson 82.10 84.81 87.00 84.64 84.64 84.64
Chris Adraktas 94.20 -99.00 93.00 93.60 93.60 .
John Brown 79.70 79.07 72.00 76.92 76.92 76.92

In addition to the mean function, SPSS also has sum, sd, variance, min and max functions.

4. String functions
Now let’s illustrate some of the SPSS string functions. Below we create up that will be the name converted into upper
case, lo that will be the name converted to lower case, and sub that will be the third through eighth character in the persons
name. Note that we first had to use the string command to tell SPSS that up lo and sub are string variables that will have a
length of up to 14 characters. Had we omitted the string command, these would have been treated as numeric variables,
and when SPSS tried to assign a character value to the numeric variables, it would have generated an error. We also
create len that is the length of the name variable, and len2 that is the length of the persons name.

STRING up lo (A14)
/sub (A6).

COMPUTE up = UPCASE(name).
COMPUTE lo = LOWER(name).
COMPUTE sub = SUBSTR(name,3,8).
COMPUTE len = LENGTH(name).
COMPUTE len2 = LENGTH(RTRIM(name)).

LIST name up lo sub len len2.

The results are shown below. The results for up lo sub all as we would expect. The result for len may be a bit confusing.
The variable len does not refer to the length of the person’s name, but it refers to the length of the variable name. When
we read the data we entered name (A14) for name, giving the variable a length of 14, and that is why len is always 14. By
contrast, len2 uses the rtrim function to strip off any excess blanks, and then it takes the length of that. In the
end, len2 returns the length of the persons name, for example John Smith has a length of 10.

NAME UP LO SUB LEN LEN2


John Smith JOHN SMITH john smith hn Smi 14.00 10.00
Samuel Adams SAMUEL ADAMS samuel adams muel A 14.00 12.00
Ben Johnson BEN JOHNSON ben johnson n John 14.00 11.00
Chris Adraktas CHRIS ADRAKTAS chris adraktas ris Ad 14.00 14.00
John Brown JOHN BROWN john brown hn Bro 14.00 10.00

Let’s use SPSS string functions to get the first name and last name out of the name variable. We start by using
the index function to determine the position of the first blank space in the name. We then use the substr function to extract
the part of the name before the blank to be the first name, and the part after the blank to be the last name.

STRING fname lname (A10).

COMPUTE blank = INDEX(name,' ').


COMPUTE fname = SUBSTR(name,1,blank-1).
COMPUTE lname = SUBSTR(name,blank+1).

LIST name blank fname lname.

The results below show that this was successful. For example, for John Smith, the substr function extracted the first name
by taking the substring from the 1st to 4th character of name, and the last name by taking the 6th character and onward.

NAME BLANK FNAME LNAME


John Smith 5.00 John Smith
Samuel Adams 7.00 Samuel Adams
Ben Johnson 4.00 Ben Johnson
Chris Adraktas 6.00 Chris Adraktas
John Brown 5.00 John Brown

5. Random number functions


Random numbers are more useful than you might imagine, they are used extensively in Monte Carlo studies, but they are
also frequently used in many other situation We will look at two of SPSS’s random number functions

 uniform(n) – generates a random number that is 0 or greater, and less than n from a uniform distribution.

 rv.binomial(n,p) – generates a value from the binomial distribution with n trials, and with a probability of

success equal to p.

Below we generate a random number that is greater than or equal to 0, but less than 1.

COMPUTE rannum = UNIFORM(1).


LIST name rannum.

We see the results below.

NAME RANNUM

John Smith .14


Samuel Adams .43
Ben Johnson .61
Chris Adraktas .29
John Brown .16

Below we generate a random number that is greater than or equal to 0, but less than 10.

COMPUTE ran10 = UNIFORM(10).


LIST NAME ran10.

And the results are shown below.

NAME RAN10

John Smith 7.00


Samuel Adams 3.46
Ben Johnson 4.46
Chris Adraktas .52
John Brown 1.03

The example below generates a whole number (integer) from 1 to 100. The trucn function is used to convert the result into
a whole number from 0 to 99, and then 1 is added to make it from 1 to 100.

COMPUTE ran100 = TRUNC(UNIFORM(100)) + 1.


LIST name ran100.

As we see below, these values are all whole numbers.

NAME RAN100

John Smith 15.00


Samuel Adams 5.00
Ben Johnson 63.00
Chris Adraktas 16.00
John Brown 72.00

Below we use the rv.binomial function to simulate a coin flip. It is like a coin flip since the number of trials is 1 and the
probability of success is .5 (like flipping a coin once and the probability of it coming up heads is .5). Let’s treat a 1 as coming
up heads, and a 0 as coming up tails. As we see below, Ben and John each got a head, and the others got tails.

COMPUTE flip = RV.BINOMIAL(1 , .5 ).


LIST name flip.
NAME FLIP
John Smith .00
Samuel Adams .00
Ben Johnson 1.00
Chris Adraktas .00
John Brown 1.00

Below, we change the number of flips to 10, and count the number of heads each person gets. John got the most heads (7)
and Ben got the fewest (4).

COMPUTE flip10 = RV.BINOMIAL(10 , .5 ).


LIST name flip10.
NAME FLIP10
John Smith 6.00
Samuel Adams 6.00
Ben Johnson 4.00
Chris Adraktas 5.00
John Brown 7.00
The next example changes the flips to 100. It also sets the seed for the random number generator. The seed determines
the string of random numbers that will be generated. John got the fewest heads (49 out of 100) and Samuel got the most
(58 out of 100).

SET SEED = 149238.


COMPUTE flip100 = RV.BINOMIAL(100 , .5 ).
LIST name flip100 .
NAME FLIP100
John Smith 49.00
Samuel Adams 58.00
Ben Johnson 52.00
Chris Adraktas 53.00
John Brown 52.00

If we repeat the example from above using the exact same seed, we will get the same results. This is very useful for being
able to replicate results of a simulation study or Monte Carlo style study. Indeed, using the same seed did generate the
same results (see below).

SET SEED = 149238.


COMPUTE flip100 = RV.BINOMIAL(100 , .5 ).
LIST name flip100 .
NAME FLIP100
John Smith 49.00
Samuel Adams 58.00
Ben Johnson 52.00
Chris Adraktas 53.00
John Brown 52.00

6. Random number functions, advanced


In the examples above, we used the rv.binomial function to simulate coin flips but it gave us the end result of all of the flips.
Perhaps you would like to do a simulation study where you generate each of the flips as a separate observation. SPSS can
do this, as we illustrate below.

SET seed=943785.
INPUT PROGRAM.
+ LOOP id = 1 to 25.
+ COMPUTE cointoss = RV.BINOMIAL( 1 , .5 ).
+ END CASE.
+ END LOOP.
+ END FILE.
END INPUT PROGRAM.

LIST CASES.

The program above creates 25 observations, each having a variable called id which is the trial number, and cointoss that
will be either 1 or 0. Even if this program does not make much sense to you, you could use it as a template to make your
own simulation. You can change the number of trials by changing 25 to the number of trials you want. You can change the
probability of success by changing the value of .5 to the value you would like. Or, you could choose an entirely different
random number generating function instead of rv.binomial you might choose uniform. The results of the program above
are shown below.

ID COINTOSS

1.00 .00
2.00 1.00
3.00 1.00
4.00 .00
5.00 .00
6.00 1.00
7.00 .00
8.00 .00
9.00 .00
10.00 .00
11.00 .00
12.00 1.00
13.00 .00
14.00 .00
15.00 .00
16.00 1.00
17.00 .00
18.00 1.00
19.00 1.00
20.00 1.00
21.00 1.00
22.00 1.00
23.00 .00
24.00 1.00
25.00 .00

Function List
This section contains a listing of all the functions in the IBM SPSS Data Collection Function Library. For full details and examples of usage,
see the Data Collection Function Library topics in the IBM® SPSS® Data Collection Scripting section of the IBM® SPSS® Data Collection
Developer Library.

Categorical Functions
Function Description
AnswerCount(Val)
Returns the number of categories selected in
a category list.
ContainsAll(Val, Answers [, Identifies whether a category list contains all
Exactly]) of the categories in a given list.
ContainsAny(Val, Answers [, Identifies whether a category list contains
Exactly]) one or more categories in a given list.
ContainsSome(Val, Answers [, Identifies whether a category list contains
Min] [, Max] [, Exactly]) some of the categories in a given list.
DefinedCategories(Val [, Returns a set of categories of a categorical
Answers]) variable.
DefinedElements(Val [, Types])
Returns a set of elements of a categorical
variable.
DefinedFactors(Val [, Returns a set of factor numbers as defined
Answers]) on the categories in a variable.
DefinedListElements(Val, Returns a set of elements of a categorical
Answers [, Types]) variable.
Function Description
Returns the difference of two category lists--
Difference(Val, Answers) that is, it returns the categories that are in
the first category list but not in the second.
Factor(Val)
Returns the factor defined for an element of
a categorical variable.
GetAnswer(Val, Index)
Returns a specified category in a category
list.
HasAnswer(Val, Answer)
Identifies whether a specified category is in a
category list.
Returns the intersection of two or more
Intersection(Val [, category lists--that is, it returns the
Vals, ...]) categories that appear in all of the category
lists.
Returns the smallest available subscript for
LBound(List [, Dimension])
the indicated dimension of an array. By
default, the lower bound is returned for the
first dimension of the array.
Returns the union of a number of categorical
Merge(Vals) values; that is, returns the categories that
are in any of the input categorical values.
ReDim(List, Size [, Preserve])
Re-sizes an array to a given size. By default,
the array contents are preserved.
Returns the largest available subscript for
UBound(List [, Dimension])
the indicated dimension of an array. By
default, the upper bound is returned for the
first dimension of the array.
Returns the union of two or more category
Union(Val [, Vals, ...]) lists--that is, it returns all of the categories
that are in one or more of the category lists.
Unique(Val)
Returns a category list with any duplicate
categories removed.
Returns the exclusive union of two category
XUnion(Val, Answers)
lists--that is, it returns all of the categories
that are in either one of the category lists,
but not in both.

Text or Categorical Functions


Function Description
Find(Val, Key [, Searches a string or category list for a specified substring
Skip [,
or subcategory list, and if it is found, returns its start
Function Description
Reverse]]) position. Note that the search is case insensitive.
Returns either a string containing the first characters from
Left(Val,
Length) a string, or a category list containing the first categories
from category list.
Len(Val)
Returns a Long containing the number of characters in a
string or the number of categories in a category list.
Returns either a string containing a specified number of
Mid(Val, Start characters from a specified position in a string, or a
[, Length]) category list containing a specified number of categories
from a specified position in a category list.
Returns either a string containing the last characters from a
Right(Val,
Length) string, or a category list containing the last categories from
category list.

Text Functions
Function Description
AscW(Val)
Returns an integer value representing the
Unicode character code for a character.
ChrW(Val)
Returns the character that corresponds to a
given Unicode character code.
Format(Val [, Style [, Returns a string that is the result of formatting a
Width [, Locale]]]) value according to a specified style.
Hex(Val)
Returns a string representing the hexadecimal
value of a number.
LCase(Val)
Returns a string that has been converted to
lower case.
LTrim(Val)
Returns a copy of a string with leading spaces
removed.
Replaces characters that are not allowed in the
MakeMDMName(Val) name of an MDM object, to produce a valid
name.
MakeString(Vals)
Returns a text string by concatenating one or
more values.
Oct(Val)
Returns a string representing the octal value of a
number.
RTrim(Val)
Returns a copy of a string with trailing spaces
removed.
Split(Val [, Delimiter [,
Count ]]) Returns an array that contains substrings.
Function Description
Trim(Val)
Returns a copy of a string with both leading
spaces and trailing spaces removed.
UCase(Val)
Returns a string that has been converted to
upper case.

Date and Time Functions


Function Description
DateAdd(Val, Interval, Count)
Returns a date to which a specified
time interval has been added.
DateDiff(Val1, Val2, Interval)
Returns the time interval between two
dates.
DateNow([ Val [, Returns the current local date in a
IgnoreDaylightSaving]]) particular time zone.
DateOnly(Val)
Returns the date from a date and time
value.
DatePart(Val, Interval)
Returns a specified part of a given
date.
Returns a whole number between 1
Day(Val) and 31, inclusive, representing the
day of the month.
GetTimeZone([Val])
Returns the index value of a time zone
defined in the registry on the server.
Returns True if daylight-saving is
GetTimeZoneDaylightSaving([Val [, currently in effect at the specified time
Time]]) in the specified time zone, or False if
not.
GetTimeZoneName([Val])
Returns the name of the local time
zone.
Returns the number of minutes to add
GetTimeZoneOffset([Val [, Time [,
IgnoreDaylightSaving]]]) to or subtract from UTC time to get
the local time.
Returns a whole number between 0
Hour(Val) and 23, inclusive, representing the
hour of the day.
LocalToUTCTime(Val [, Zone [, Returns the UTC time that
IgnoreDaylightSaving]]) corresponds to a given local time.
Returns a whole number between 0
Minute(Val) and 59, inclusive, representing the
minute of the hour.
Function Description
Returns a whole number between 1
Month(Val) and 12, inclusive, representing the
month of the year.
MonthName(Val [, Abbreviate [, Locale Returns a string indicating the
] ]) specified month.
Now([ Val [, IgnoreDaylightSaving]])
Returns the current local date and
time in a particular time zone.
Returns a whole number between 0
Second(Val) and 59, inclusive, representing the
second of the minute.
SetTimeZone(Val) Sets the time zone for a program.
TimeNow([ Val [, Returns the current local time in a
IgnoreDaylightSaving]]) particular time zone.
TimeOnly(Val)
Returns the time from a date and time
value.
UTCToLocalTime(Val [, Zone [, Returns the local time that
IgnoreDaylightSaving]]) corresponds to a given UTC time.
WeekdayName(Val [, Abbreviate [, Returns a string indicating the
Locale ] ]) specified day of the week.
Year(Val)
Returns a whole number representing
the year.

Conversion Functions
Function Description
CBoolean(Val) Converts a value of any data type to a Boolean value.
CCategorical(Val) Converts a value of any data type to a Categorical value.
CDate(Val) Converts a value of any data type to a Date value.
CDouble(Val) Converts a value of any data type to a Double value.
CLong(Val) Converts a value of any data type to a Long value.
CText(Val) Converts a value of any data type to a Text value.

Random Number Functions


Function Description
GetRandomSeed()
Returns the current starting point of the random
number generator.
RanInt([Seed]) Returns a random integer number.
Rnd([Seed]) Returns a random decimal number.
Function Description
SetRandomSeed([Seed])
Sets the starting point for the random number
generator.

List Functions
Function Description
FindItem(List, Key)
Returns a specified item from a list, or NULL if
the item isn't found.
GetReversalSeed()
Returns the current reversal state (which is
used by the Rev function).
GetRotationSeed()
Returns the current rotation state (which is used
by the Rot function).
Returns a randomized copy of a list. An optional
Ran(List [, Count [,
Seed]]) parameter defines how many items from the
input list are included in the randomized list.
RanSequence(Start, End [, Returns an array containing values selected
Step [, Count[, Seed]]]) randomly from a given series of integers.
Returns an array containing copies of items
from an input list, either in the normal order or
Rev(List [, Count [, Policy
[, Seed]]]) in reverse order. The optional Count parameter
defines how many items from the input list are
included in the returned list.
RevSequence(Start, End [, Returns an array containing values selected
Step [, Count[, Policy[, from a given series of integers, either in the
Seed]]]]) original order or in reverse order.
Returns an array containing copies of items
from the input list, in a rotated order. The
Rot(List [, Count [, Policy
[, Seed]]]) optional Count parameter defines how many
items from the input list are included in the
returned list.
RotSequence(Start, End [, Returns an array containing values selected
Step [, Count[, Policy[, from a given series of integers in a "rotated"
Seed]]]]) order.

SelectRange(List [, Range Returns an array containing copies of selected


[, Count]]) items from the input list.

SetReversalSeed([Seed]) Sets the reversal state.


SetRotationSeed([Seed]) Sets the rotation state.
SortAsc(List [, Count [, Returns an array containing copies of items
IgnoreLocale]])
from the input list, sorted in ascending order.
Function Description
The optional Count parameter defines how
many items from the input list are included in
the returned list.
Returns an array containing copies of items
from the input list, sorted in descending order.
SortDesc(List [, Count [,
IgnoreLocale ]]) The optional Count parameter defines how
many items from the input list are included in
the returned list.

Mathematical Functions
Function Description
Abs(Val) Returns the absolute value of a number.
Atn(Val) Returns the arctangent of a number.
Cos(Val) Returns the cosine of an angle.
Exp(Val)
Returns e (the base of natural logarithms) raised to a
power.
Int(Val) Returns the integer portion of a number.
Log(Val [, Base]) Returns the logarithm of a number.
MaxOf(Val1 [,
Vals, ...]) Returns the maximum of two or more values.
MinOf(Val1 [,
Vals, ...]) Returns the minimum of two or more values.
Pow(Val1, Val2) Returns the value of a number raised to a power.
Round(Val [, Digits Returns a number rounded to a specified number of
[, Policy]]) decimal places or significant digits.
Sgn(Val)
Returns an integer that indicates the sign of a
number.
Sin(Val) Returns the sine of an angle.
Sqrt(Val) Returns the square root of a number.
Tan(Val) Returns the tangent of an angle.

Miscellaneous Functions
Function Description
Calculates categories (called bands) for a
Band(Val, Min, Size [, numeric variable and returns the appropriate
Count]) category for a specified value in the numeric
variable.
BitAnd(Val1 [, Vals, ...]) Performs a bitwise AND on two or more
Function Description
numeric values and returns the result.
BitNot(Val)
Performs a bitwise NOT on a numeric value
and returns the result.
BitOr(Val1 [, Vals, ...])
Performs a bitwise OR on two or more numeric
values and returns the result.
BitXor(Val1 [, Vals, ...])
Performs a bitwise XOR on two or more
numeric values and returns the result.
CreateObject(Class)
Creates and returns a reference to an
Automation object.
DBNull() Returns a NULL data value for use with ADO.
EngineVersion([Val [, Returns part or all of the engine's version
Number]]) number.
Calculates a specified number of equal
EqualBand(Val, Count, Min, categories (called bands) for a numeric
Max) variable and returns the appropriate category
for a specified value in the numeric variable.
Eval(Expr)
Evaluates an expression and returns the
result.
Execute(Script) Executes one or more specified statements.
GetInterface(Object,
InterfaceID) Returns an alternate interface for an object.
Returns the value passed as
IIf(Val, TruePart, FalsePart)
the TruePart parameter if the expression
evaluates to True, otherwise returns the value
passed as the FalsePart parameter.
Displays a dialog box containing a specified
InputBox(Prompt[, Default[,
Title]]) message, a text box for input, an OK button,
and a Cancel button.
IsDBNull(Val)
Returns true if a value is a NULL data value
that can be used by ADO.

IsElementInVersions(Val, Tests whether an element or list exists in all


Elem, Versions) specified versions of a variable.

Returns True if the value is empty. A string


containing no characters or just containing
IsEmpty(Val)
white spaces is considered to be empty. A
category list containing no categories is
considered to be empty. All other data types
are always considered to be not empty.
IsEqualObject(Val1, Val2) Returns True if two values refer to the same
Function Description
object.
Returns true if an variable is NULL, without
IsNullObject(Val) testing the default property of the object being
referenced.
IsOneOf(Val1 [, Vals, ...])
Returns true if a value is equal to at least one
of the other listed values.
IsSet(Val, Mask)
Returns True if an integer value matches a
specified mask.
Replace(Val, Key, Replacement
[, Start [, Count [,
Replaces part of a text or categorical value
IgnoreCase]]]) with another value of the same type.

RGB(Red, Green, Blue)


Returns a number representing an RGB color
value.
ShellExecute(File [, HWnd [,
Verb [, Parameters [, Performs an operation on a specified file.
Directory [, ShowCmd]]]]])
Sleep(Val) Suspends the thread in which it is called.
Validates a specified value based on specified
Validate(Val [, Min [, Max [,
Expr [, Describe ] ] ] ]) minimum and maximum values and optionally
a validating expression.
VarType(Val)
Returns a numeric value indicating the
subtype of a variable.
VarTypeName(Val)
Returns a string indicating the subtype of a
variable.

SPSS commands come in 3 basic types:


1. transformations are commands that are not immediately executed. Most
transformations (IF, RECODE, COMPUTE, COUNT) are used for creating
new variables. Transformations can be used in loops (DO REPEAT or LOOP)
and/or conditionally (DO IF).
2. procedures are commands that inspect all cases in the active dataset.
Procedures are mostly used for data analysis such as running charts, tables
and statistical tests. Procedures also cause transformations to be executed.
3. other commands are neither transformations, nor procedures.

You might also like