Data Transformations in SPSS
Data Transformations in SPSS
Computing Variables
data transformations,data transformations,data transformations
computing variables,computing variables,computing variables
computing variables,computing variables,computing variables
Use the Compute dialog box to compute values for a variable based on numeric transformations of other
variables.
You can compute values for numeric or string (alphanumeric) variables.
You can create new variables or replace the values of existing variables. For new variables, you
can also specify the variable type and label.
You can compute values selectively for subsets of data based on logical conditions.
You can use more than 70 built-in functions, including arithmetic functions, statistical functions,
distribution functions, and string functions.
To Compute Variables
Related Topics
Compute Variable: If Cases
Compute Variable: Type and Label
Functions
Missing Values in Functions
COMPUTE
Previous Next
Compute Variable: If Cases
data transformations,data transformations,data transformations
conditional transformations,conditional transformations,conditional transformations
conditional transformations,conditional transformations,conditional transformations
The If Cases dialog box allows you to apply data transformations to selected subsets of cases, using
conditional expressions. A conditional expression returns a value of true, false, or missing for each case.
If the result of a conditional expression is true, the case is included in the selected subset.
If the result of a conditional expression is false or missing, the case is not included in the selected
subset.
Most conditional expressions use one or more of the six relational operators (<, >, <=, >=, =, and
~=) on the calculator pad.
Conditional expressions can include variable names, constants, arithmetic operators, numeric (and
other) functions, logical variables, and relational operators.
Specifying Conditional Transformations
Page 1 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Related Topics
Computing Variables
Compute Variable: Type and Label
Functions
Missing Values in Functions
Previous Next
Compute Variable: Type and Label
string variables,string variables,string variables
computing new string variables,computing new string variables,computing new string variables
computing variables,computing variables,computing variables
computing new string variables,computing new string variables,computing new string variables
data transformations,data transformations,data transformations
string variables,string variables,string variables
By default, new computed variables are numeric. To compute a new string variable, you must specify
the data type and width.
Label. Optional, descriptive variable label up to 120 characters long. You can enter a label or use the
first 110 characters of the Compute expression as the label.
Type. Computed variables can be numeric or string (alphanumeric). String variables cannot be used in
calculations.
Specifying Type and Label for Computed Variables
Related Topics
Computing Variables
Compute Variable: If Cases
Functions
Missing Values in Functions
Previous Next
Functions
functions,functions,functions
data transformations,data transformations,data transformations
functions,functions,functions
Many types of functions are supported, including:
Arithmetic functions. See Arithmetic Functions for more information.
Statistical functions. See Statistical Functions for more information.
Page 2 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
String functions. See String Functions for more information.
Date and time functions. See Date and Time Functions for more information.
Distribution functions. See Random Variable and Distribution Functions for more information.
Random variable functions. See Random Variable and Distribution Functions for more
information.
Missing value [Link] Missing Value Functions for more information.
Scoring functions (SPSS Server only). See Scoring Expressions (SPSS Server) for more
information.
Related Topics
Select Cases: If
Computing Variables
Compute Variable: If Cases
Compute Variable: Type and Label
Missing Values in Functions
Previous Next
Missing Values in Functions
missing values,missing values,missing values
in functions,in functions,in functions
functions,functions,functions
missing value treatment,missing value treatment,missing value treatment
Functions and simple arithmetic expressions treat missing values in different ways. In the expression:
(var1+var2+var3)/3
the result is missing if a case has a missing value for any of the three variables.
In the expression:
MEAN(var1, var2, var3)
the result is missing only if the case has missing values for all three variables.
For statistical functions, you can specify the minimum number of arguments that must have nonmissing
values. To do so, type a period and the minimum number after the function name, as in:
MEAN.2(var1, var2, var3)
Related Topics
Computing Variables
Compute Variable: If Cases
Compute Variable: Type and Label
Functions
Page 3 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Previous Next
Random Number Generators
random number seed,random number seed,random number seed
random sample,random sample,random sample
random number seed,random number seed,random number seed
The Random Number Generators dialog box allows you to select the random number generator and set
the starting sequence value so you can reproduce a sequence of random numbers.
Active Generator. Two different random number generators are available:
SPSS 12 Compatible. The random number generator used in SPSS 12 and previous releases. If
you need to reproduce randomized results generated in previous releases based on a specified seed
value, use this random number generator.
Mersenne Twister. A newer random number generator that is more reliable for simulation
purposes. If reproducing randomized results from SPSS 12 or earlier is not an issue, use this
random number generator.
Active Generator Initialization. The random number seed changes each time a random number is
generated for use in transformations (such as random distribution functions), random sampling, or case
weighting. To replicate a sequence of random numbers, set the initialization starting point value prior to
each analysis that uses the random numbers. The value must be a positive integer.
To select the random number generator and/or set the initialization value:
Related Topics
To Cache Data Automatically
Select Cases: Random Sample
Case Selection Status in the Data Editor
Split File
Previous Next
Count Occurrences of Values within Cases
counting occurrences,counting occurrences,counting occurrences
This dialog box creates a variable that counts the occurrences of the same value(s) in a list of variables
for each case. For example, a survey might contain a list of magazines with yes/no check boxes to
indicate which magazines each respondent reads. You could count the number of yes responses for each
respondent to create a new variable that contains the total number of magazines read.
To Count Occurrences of Values within Cases
Page 4 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Related Topics
Count Values within Cases: Values to Count
Count Occurrences: If Cases
COUNT
Previous Next
Count Values within Cases: Values to Count
The value of the target variable (on the main dialog box) is incremented by 1 each time one of the
selected variables matches a specification in the Values to Count list here. If a case matches several
specifications for any variable, the target variable is incremented several times for that variable.
Value specifications can include individual values, missing or system-missing values, and ranges.
Ranges include their endpoints and any user-missing values that fall within the range.
Specifying Values to Count
Related Topics
Count Occurrences of Values within Cases
Count Occurrences: If Cases
Previous Next
Count Occurrences: If Cases
The If Cases dialog box allows you to count occurrences of values for a selected subset of cases, using
conditional expressions. A conditional expression returns a value of true, false, or missing for each case.
If the result of a conditional expression is true, the case is included in the selected subset.
If the result of a conditional expression is false or missing, the case is not included in the selected
subset.
Most conditional expressions use one or more of the six relational operators (<, >, <=, >=, =, and
~=) on the calculator pad.
Conditional expressions can include variable names, constants, arithmetic operators, numeric (and
other) functions, logical variables, and relational operators.
Counting Occurrences for a Subset of Cases
Related Topics
Count Occurrences of Values within Cases
Count Values within Cases: Values to Count
Previous Next
Page 5 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Recode into Same Variables
variables,variables,variables
recoding,recoding,recoding
recoding values,recoding values,recoding values
data transformations,data transformations,data transformations
recoding values,recoding values,recoding values
The Recode into Same Variables dialog box allows you to reassign the values of existing variables or
collapse ranges of existing values into new values. For example, you could collapse salaries into salary
range categories.
You can recode numeric and string variables. If you select multiple variables, they must all be the same
type. You cannot recode numeric and string variables together.
To Recode Values of a Variable
Specifying Values to Recode
Related Topics
Visual Binning
Recode into Different Variables
Automatic Recode
Recode into Same Variables: Old and New Values
Recode into Same Variables: If Cases
RECODE
Previous Next
Recode into Same Variables: Old and New
Values
variables,variables,variables
recoding,recoding,recoding
recoding values,recoding values,recoding values
data transformations,data transformations,data transformations
recoding values,recoding values,recoding values
You can define values to recode in this dialog box. All value specifications must be the same data type
(numeric or string) as the variables selected in the main dialog box.
Old Value. The value(s) to be recoded. You can recode single values, ranges of values, and missing
values. System-missing values and ranges cannot be selected for string variables because neither concept
applies to string variables. Ranges include their endpoints and any user-missing values that fall within
the range.
Show details
Page 6 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
New Value. The single value into which each old value or range of values is recoded. You can enter a
value or assign the system-missing value.
Show details
Old>New. The list of specifications that will be used to recode the variable(s). You can add, change,
and remove specifications from the list. The list is automatically sorted, based on the old value
specification, using the following order: single values, missing values, ranges, and all other values. If
you change a recode specification on the list, the procedure automatically re-sorts the list, if necessary,
to maintain this order.
Related Topics
Recode into Same Variables
Recode into Same Variables: If Cases
Previous Next
Recode into Same Variables: If Cases
The If Cases dialog box allows you to recode values for a selected subset of cases, using conditional
expressions. A conditional expression returns a value of true, false, or missing for each case.
If the result of a conditional expression is true, the case is included in the selected subset.
If the result of a conditional expression is false or missing, the case is not included in the selected
subset.
Most conditional expressions use one or more of the six relational operators (<, >, <=, >=, =, and
~=) on the calculator pad.
Conditional expressions can include variable names, constants, arithmetic operators, numeric (and
other) functions, logical variables, and relational operators.
Recoding Values for a Subset of Cases
Related Topics
Recode into Same Variables
Recode into Same Variables: Old and New Values
Previous Next
Recode into Different Variables
variables,variables,variables
recoding,recoding,recoding
recoding values,recoding values,recoding values
data transformations,data transformations,data transformations
recoding values,recoding values,recoding values
Page 7 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
The Recode into Different Variables dialog box allows you to reassign the values of existing variables or
collapse ranges of existing values into new values for a new variable. For example, you could collapse
salaries into a new variable containing salary-range categories.
You can recode numeric and string variables.
You can recode numeric variables into string variables and vice versa.
If you select multiple variables, they must all be the same type. You cannot recode numeric and
string variables together.
To Recode Values of a Variable into a New Variable
Specifying Values to Recode for New Variables
Related Topics
Recode into Same Variables
Automatic Recode
Recode into Different Variables: Old and New Values
Recode into Different Variables: If Cases
RECODE
Previous Next
Recode into Different Variables: Old and New
Values
variables,variables,variables
recoding,recoding,recoding
recoding values,recoding values,recoding values
data transformations,data transformations,data transformations
recoding values,recoding values,recoding values
You can define values to recode in this dialog box.
Old Value. The value(s) to be recoded. You can recode single values, ranges of values, and missing
values. System-missing values and ranges cannot be selected for string variables because neither concept
applies to string variables. Old values must be the same data type (numeric or string) as the original
variable. Ranges include their endpoints and any user-missing values that fall within the range.
Show details
New Value. The single value into which each old value or range of values is recoded. New values can be
numeric or string.
Show details
Output variables are strings. Defines the new, recoded variable as a string (alphanumeric) variable. The
old variable can be numeric or string.
Page 8 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Convert numeric strings to numbers. Converts string values containing numbers to numeric values.
Strings containing anything other than numbers and an optional sign (+ or -) are assigned the system-
missing value.
Old>New. The list of specifications that will be used to recode the variable(s). You can add, change,
and remove specifications from the list. The list is automatically sorted, based on the old value
specification, using the following order: single values, missing values, ranges, and all other values. If
you change a recode specification on the list, the procedure automatically re-sorts the list, if necessary,
to maintain this order.
Related Topics
Recode into Different Variables
Recode into Different Variables: If Cases
Previous Next
Recode into Different Variables: If Cases
The If Cases dialog box allows you to recode values for a selected subset of cases, using conditional
expressions. A conditional expression returns a value of true, false, or missing for each case.
If the result of a conditional expression is true, the case is included in the selected subset.
If the result of a conditional expression is false or missing, the case is not included in the selected
subset.
Most conditional expressions use one or more of the six relational operators (<, >, <=, >=, =, and
~=) on the calculator pad.
Conditional expressions can include variable names, constants, arithmetic operators, numeric (and
other) functions, logical variables, and relational operators.
Recoding Values for a Subset of Cases
Related Topics
Recode into Different Variables
Recode into Different Variables: Old and New Values
Previous Next
Rank Cases
ranking cases,ranking cases,ranking cases
data transformations,data transformations,data transformations
ranking cases,ranking cases,ranking cases
The Rank Cases dialog box allows you to create new variables containing ranks, normal and Savage
scores, and percentile values for numeric variables.
Page 9 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
New variable names and descriptive variable labels are automatically generated, based on the original
variable name and the selected measure(s). A summary table lists the original variables, the new
variables, and the variable labels.
Optionally, you can:
Rank cases in ascending or descending order.
Organize rankings into subgroups by selecting one or more grouping variables for the By list.
Ranks are computed within each group. Groups are defined by the combination of values of the
grouping variables. For example, if you select gender and minority as grouping variables, ranks
are computed for each combination of gender and minority.
To Rank Cases
Related Topics
Rank Cases: Types
Rank Cases: Ties
RANK
Previous Next
Rank Cases: Types
Blom estimates,Blom estimates,Blom estimates
Tukey estimates,Tukey estimates,Tukey estimates
Rankit estimates,Rankit estimates,Rankit estimates
Van der Waerden estimates,Van der Waerden estimates,Van der Waerden estimates
ranking cases,ranking cases,ranking cases
Savage scores,Savage scores,Savage scores
Savage scores,Savage scores,Savage scores
ranking cases,ranking cases,ranking cases
fractional ranks,fractional ranks,fractional ranks
ranking cases,ranking cases,ranking cases
percentiles,percentiles,percentiles
proportion estimates,proportion estimates,proportion estimates
in Rank Cases,in Rank Cases,in Rank Cases
normal scores,normal scores,normal scores
in Rank Cases,in Rank Cases,in Rank Cases
z scores,z scores,z scores
in Rank Cases,in Rank Cases,in Rank Cases
You can select multiple ranking methods. A separate ranking variable is created for each method.
Ranking methods include simple ranks, Savage scores, fractional ranks, and percentiles. You can also
create rankings based on proportion estimates and normal scores.
Show details
Proportion estimates. Estimates of the cumulative proportion of the distribution corresponding to a
Page 10 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
particular rank.
Normal scores. The z scores corresponding to the estimated cumulative proportion.
Proportion Estimation Formula. For proportion estimates and normal scores, you can select the
proportion estimation formula: Blom, Tukey, Rankit, or Van der Waerden.
Show details
Selecting Ranking Methods
Related Topics
Rank Cases
Rank Cases: Ties
Previous Next
Rank Cases: Ties
ranking cases,ranking cases,ranking cases
tied values,tied values,tied values
This dialog box controls the method for assigning rankings to cases with the same value on the original
variable.
The following table shows how the different methods assign ranks to tied values:
Assigning Ranks to Tied Values
Related Topics
Rank Cases
Rank Cases: Types
Previous Next
Automatic Recode
variables,variables,variables
recoding,recoding,recoding
Value Mean Low High Sequential
10 1 1 1 1
15 3 2 4 2
15 3 2 4 2
15 3 2 4 2
16 5 5 5 3
20 6 6 6 4
Page 11 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
recoding values,recoding values,recoding values
data transformations,data transformations,data transformations
recoding values,recoding values,recoding values
string variables,string variables,string variables
recoding into consecutive integers,recoding into consecutive integers,recoding into consecutive integers
The Automatic Recode dialog box allows you to convert string and numeric values into consecutive
integers. When category codes are not sequential, the resulting empty cells reduce performance and
increase memory requirements for many procedures. Additionally, some procedures cannot use string
variables, and some require consecutive integer values for factor levels.
The new variable(s) created by Automatic Recode retain any defined variable and value labels
from the old variable. For any values without a defined value label, the original value is used as
the label for the recoded value. A table displays the old and new values and value labels.
String values are recoded in alphabetical order, with uppercase letters preceding their lowercase
counterparts.
Missing values are recoded into missing values higher than any nonmissing values, with their
order preserved. For example, if the original variable has 10 nonmissing values, the lowest
missing value would be recoded to 11, and the value 11 would be a missing value for the new
variable.
Use the same recoding scheme for all variables. This option allows you to apply a single autorecoding
scheme to all the selected variables, yielding a consistent coding scheme for all the new variables.
Show details
Treat blank string values as user-missing. For string variables, blank or null values are not treated as
system-missing. This option will autorecode blank strings into a user-missing value higher than the
highest non-missing value.
Templates
You can save the autorecoding scheme in a template file and then apply it to other variables and other
data files.
For example, you may have a large number of alphanumeric product codes that you autorecode into
integers every month, but some months new product codes are added that change the original
autorecoding scheme. If you save the original scheme in a template and then apply it to the new data that
contain the new set of codes, any new codes encountered in the data are autorecoded into values higher
that the last value in the template, preserving the original autorecode scheme of the original product
codes.
Show details
To Recode String or Numeric Values into Consecutive Integers
Related Topics
Recode into Same Variables
Recode into Different Variables
Page 12 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Binomial Test: Related Procedures
Chi-Square Test: Related Procedures
Runs Test: Related Procedures
AUTORECODE
Previous Next
Date and Time Wizard
date format variables,date format variables,date format variables
create date/time variable from string,create date/time variable from string,create date/time variable from
string
create date/time variable from set of variables,create date/time variable from set of variables,create
date/time variable from set of variables
add or subtract from date/time variables,add or subtract from date/time variables,add or subtract from
date/time variables
extract part of date/time variable,extract part of date/time variable,extract part of date/time variable
The Date and Time Wizard simplifies a number of common tasks associated with date and time
variables.
To Use the Date and Time Wizard
Learn how dates and times are represented in SPSS. This choice leads to a screen that provides a
brief overview of date/time variables in SPSS. By clicking on the Help button, it also provides a
link to more detailed information.
Create a date/time variable from a string containing a date or time. Use this option to create a
date/time variable from a string variable. For example, you have a string variable representing
dates in the form mm/dd/yyyy and want to create a date/time variable from this.
Create a date/time variable from variables holding parts of dates or times. This choice allows you
to construct a date/time variable from a set of existing variables. For example, you have a variable
that represents the month (as an integer), a second that represents the day of the month, and a third
that represents the year. You can combine these three variables into a single date/time variable.
Calculate with dates and times. Use this option to add or subtract values from date/time variables.
For example, you can calculate the duration of a process by subtracting a variable representing the
start time of the process from another variable representing the end time of the process.
Extract a part of a date or time variable. This option allows you to extract part of a date/time
variable, such as the day of the month from a date/time variable, which has the form mm/dd/yyyy.
Assign periodicity to a dataset. This choice takes you to the Define Dates dialog box, used to
create date/time variables that consist of a set of sequential dates. This feature is typically used to
associate dates with time series data.
Note: Tasks are disabled when the dataset lacks the types of variables required to accomplish the task.
For instance, if the dataset contains no string variables, then the task to create a date/time variable from a
string does not apply and is disabled.
Related Topics
Dates and Times in SPSS
Page 13 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Create a Date/Time Variable from a String
Create a Date/Time Variable from a Set of Variables
Add or Subtract Values from Date/Time Variables
Select Type of Calculation to Perform with Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Date-Format Variables
Subtract Duration Variables
Extract Part of a Date/Time Variable
Date and Time Functions
Previous Next
Dates and Times in SPSS
Variables that represent dates and times in SPSS have a variable type of numeric, with display formats
that correspond to the specific date/time formats. These variables are generally referred to as date/time
variables. SPSS distinguishes between date/time variables that actually represent dates and those that
represent a time duration that is independent of any date, such as 20 hours, 10 minutes and 15 seconds.
The latter are referred to as duration variables and the former as date or date/time variables. For a
complete list of display formats, see Date and Time Formats .
Date and date/time variables. Date variables have a format representing a date, such as mm/dd/yyyy.
Date/time variables have a format representing a date and time, such as dd-mmm-yyyy hh:mm:ss.
Internally, date and date/time variables are stored as the number of seconds from October 14, 1582. Date
and date/time variables are sometimes referred to as date-format variables.
Both two- and four-digit year specifications are recognized. By default, two-digit years represent a
range beginning 69 years prior to the current date and ending 30 years after the current date. This
range is determined by your Options settings and is configurable (from the Edit menu, choose
Options and click the Data tab).
Dashes, periods, commas, slashes, or blanks can be used as delimiters in day-month-year formats.
Months can be represented in digits, Roman numerals, or three-character abbreviations, and they
can be fully spelled out. Three-letter abbreviations and fully spelled-out month names must be in
English; month names in other languages are not recognized.
Duration Variables. Duration variables have a format representing a time duration, such as hh:mm. They
are stored internally as seconds without reference to a particular date.
In time specifications (applies to date/time and duration variables), colons can be used as
delimiters between hours, minutes, and seconds. Hours and minutes are required, but seconds are
optional. A period is required to separate seconds from fractional seconds. Hours can be of
unlimited magnitude, but the maximum value for minutes is 59 and for seconds is 59.999....
Current Date and Time. The system variable $TIME holds the current date and time. It represents the
number of seconds from October 14, 1582, to the date and time when the transformation command that
uses it is executed.
Related Topics
Date and Time Wizard
Page 14 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Create a Date/Time Variable from a String
Create a Date/Time Variable from a Set of Variables
Add or Subtract Values from Date/Time Variables
Select Type of Calculation to Perform with Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Date-Format Variables
Subtract Duration Variables
Extract Part of a Date/Time Variable
Previous Next
Create a Date/Time Variable from a String
To create a date/time variable from a string variable:
Select Create a date/time variable from a string containing a date or time on the introduction screen of
the Date and Time Wizard.
Related Topics
Date and Time Wizard
Dates and Times in SPSS
Create a Date/Time Variable from a Set of Variables
Add or Subtract Values from Date/Time Variables
Select Type of Calculation to Perform with Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Date-Format Variables
Subtract Duration Variables
Extract Part of a Date/Time Variable
Previous Next
Select String Variable to Convert to Date/Time
Variable
Select the string variable to convert in the Variables list. Note that the list displays only string
variables.
Select the pattern from the Patterns list that matches how dates are represented by the string variable.
The Sample Values list displays actual values of the selected variable in the data file. Values of the
string variable that do not fit the selected pattern result in a value of system-missing for the new
variable.
Related Topics
Specify Result of Converting String Variable to Date/Time Variable
Previous Next
Page 15 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Specify Result of Converting String Variable to
Date/Time Variable
Enter a name for the Result Variable. This cannot be the name of an existing variable.
Optionally, you can:
Select a date/time format for the new variable from the Output Format list.
Assign a descriptive variable label to the new variable.
Related Topics
Select String Variable to Convert to Date/Time Variable
Previous Next
Create a Date/Time Variable from a Set of
Variables
To merge a set of existing variables into a single date/time variable:
Select Create a date/time variable from variables holding parts of dates or times on the introduction
screen of the Date and Time Wizard.
Related Topics
Date and Time Wizard
Dates and Times in SPSS
Create a Date/Time Variable from a String
Add or Subtract Values from Date/Time Variables
Select Type of Calculation to Perform with Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Date-Format Variables
Subtract Duration Variables
Extract Part of a Date/Time Variable
Previous Next
Select Variables to Merge into Single Date/Time
Variable
Select the variables that represent the different parts of the date/time.
Some combinations of selections are not allowed. For instance, creating a date/time variable from
Year and Day of Month is invalid because once Year is chosen, a full date is required.
Page 16 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
You cannot use an existing date/time variable as one of the parts of the final date/time variable
youre creating. Variables that make up the parts of the new date/time variable must be integers.
The exception is the allowed use of an existing date/time variable as the Seconds part of the new
variable. Since fractional seconds are allowed, the variable used for Seconds is not required to be
an integer.
Values, for any part of the new variable, that are not within the allowed range result in a value of
system-missing for the new variable. For instance, if you inadvertently use a variable representing
day of month for Month. Since the valid range for months in SPSS is 113, any cases with day of
month values in the range 1431 will be assigned the system-missing value for the new variable.
Related Topics
Specify Date/Time Variable Created by Merging Variables
Previous Next
Specify Date/Time Variable Created by Merging
Variables
Enter a name for the Result Variable. This cannot be the name of an existing variable.
Select a date/time format from the Output Format list.
Optionally, you can:
Assign a descriptive variable label to the new variable.
Related Topics
Select Variables to Merge into Single Date/Time Variable
Previous Next
Add or Subtract Values from Date/Time
Variables
To add or subtract values from date/time variables:
Select Calculate with dates and times on the introduction screen of the Date and Time Wizard.
Related Topics
Date and Time Wizard
Dates and Times in SPSS
Create a Date/Time Variable from a String
Create a Date/Time Variable from a Set of Variables
Page 17 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Select Type of Calculation to Perform with Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Date-Format Variables
Subtract Duration Variables
Extract Part of a Date/Time Variable
Previous Next
Select Type of Calculation to Perform with
Date/Time Variables
Add or subtract a duration from a date. Use this option to add to or subtract from a date-format
variable. You can add or subtract durations that are fixed values, such as 10 days, or the values
from a numeric variable, such as a variable that represents years.
Calculate the number of time units between two dates. Use this option to obtain the difference
between two dates as measured in a chosen unit. For example, you can obtain the number of years
or the number of days separating two dates.
Subtract two durations. Use this option to obtain the difference between two variables that have
formats of durations, such as hh:mm or hh:mm:ss.
Note: Tasks are disabled when the dataset lacks the types of variables required to accomplish the task.
For instance, if the dataset lacks two variables with formats of durations, then the task to subtract two
durations does not apply and is disabled.
Related Topics
Date and Time Wizard
Dates and Times in SPSS
Create a Date/Time Variable from a String
Create a Date/Time Variable from a Set of Variables
Add or Subtract Values from Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Date-Format Variables
Subtract Duration Variables
Extract Part of a Date/Time Variable
Previous Next
Add or Subtract a Duration from a Date
To add or subtract a duration from a date-format variable:
Select Calculate with dates and times on the introduction screen of the Date and Time Wizard.
Select Add or subtract a duration from a date on the screen of the Date and Time Wizard labeled Do
Calculations on Dates.
Related Topics
Page 18 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Date and Time Wizard
Dates and Times in SPSS
Create a Date/Time Variable from a String
Create a Date/Time Variable from a Set of Variables
Add or Subtract Values from Date/Time Variables
Select Type of Calculation to Perform with Date/Time Variables
Subtract Date-Format Variables
Subtract Duration Variables
Extract Part of a Date/Time Variable
Previous Next
Select Date/Time Variable and Duration to Add
or Subtract
Select a date (or time) variable.
Select a duration variable or enter a value for Duration Constant. Variables used for durations cannot
be date or date/time variables. They can be duration variables or simple numeric variables.
Select the unit that the duration represents from the drop-down list. Select Duration if using a variable
and the variable is in the form of a duration, such as hh:mm or hh:mm:ss.
Related Topics
Specify Result of Adding or Subtracting a Duration from a Date/Time Variable
Previous Next
Specify Result of Adding or Subtracting a
Duration from a Date/Time Variable
Enter a name for Result Variable. This cannot be the name of an existing variable.
Optionally, you can:
Assign a descriptive variable label to the new variable.
Related Topics
Select Date/Time Variable and Duration to Add or Subtract
Previous Next
Subtract Date-Format Variables
Page 19 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
To subtract two date-format variables:
Select Calculate with dates and times on the introduction screen of the Date and Time Wizard.
Select Calculate the number of time units between two dates on the screen of the Date and Time
Wizard labeled Do Calculations on Dates.
Related Topics
Date and Time Wizard
Dates and Times in SPSS
Create a Date/Time Variable from a String
Create a Date/Time Variable from a Set of Variables
Add or Subtract Values from Date/Time Variables
Select Type of Calculation to Perform with Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Duration Variables
Extract Part of a Date/Time Variable
Previous Next
Select Date-Format Variables to Subtract
Select the variables to subtract.
Select the unit for the result from the drop-down list.
Related Topics
Specify Result of Subtracting Two Date-Format Variables
Previous Next
Specify Result of Subtracting Two Date-Format
Variables
Enter a name for Result Variable. This cannot be the name of an existing variable.
Optionally, you can:
Assign a descriptive variable label to the new variable.
Related Topics
Select Date-Format Variables to Subtract
Previous Next
Page 20 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Subtract Duration Variables
To subtract two duration variables:
Select Calculate with dates and times on the introduction screen of the Date and Time Wizard.
Select Subtract two durations on the screen of the Date and Time Wizard labeled Do Calculations on
Dates.
Related Topics
Date and Time Wizard
Dates and Times in SPSS
Create a Date/Time Variable from a String
Create a Date/Time Variable from a Set of Variables
Add or Subtract Values from Date/Time Variables
Select Type of Calculation to Perform with Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Date-Format Variables
Extract Part of a Date/Time Variable
Previous Next
Select Duration Variables to Subtract
Select the variables to subtract.
Related Topics
Specify Result of Subtracting Two Duration Variables
Previous Next
Specify Result of Subtracting Two Duration
Variables
Enter a name for Result Variable. This cannot be the name of an existing variable.
Select a duration format from the Output Format list.
Optionally, you can:
Assign a descriptive variable label to the new variable.
Related Topics
Page 21 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Select Duration Variables to Subtract
Previous Next
Extract Part of a Date/Time Variable
To extract a component--such as the year--from a date/time variable:
Select Extract a part of a date or time variable on the introduction screen of the Date and Time Wizard.
Related Topics
Date and Time Wizard
Dates and Times in SPSS
Create a Date/Time Variable from a String
Create a Date/Time Variable from a Set of Variables
Add or Subtract Values from Date/Time Variables
Select Type of Calculation to Perform with Date/Time Variables
Add or Subtract a Duration from a Date
Subtract Date-Format Variables
Subtract Duration Variables
Previous Next
Select Component to Extract from Date/Time
Variable
Select the variable containing the date or time part to extract.
Select the part of the variable to extract, from the drop-down list. You can extract information from
dates that is not explicitly part of the display date, such as day of the week.
Related Topics
Specify Result of Extracting Component from Date/Time Variable
Previous Next
Specify Result of Extracting Component from
Date/Time Variable
Enter a name for Result Variable. This cannot be the name of an existing variable.
If you're extracting the date or time part of a date/time variable, then you must select a format from the
Output Format list. In cases where the output format is not required, the Output Format list will be
disabled.
Page 22 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Optionally, you can:
Assign a descriptive variable label to the new variable.
Related Topics
Select Component to Extract from Date/Time Variable
Previous Next
Time Series Data Transformations
time series data,time series data,time series data
data transformations,data transformations,data transformations
data transformations,data transformations,data transformations
time series,time series,time series
Several data transformations that are useful in time series analysis are provided:
Generate date variables to establish periodicity and to distinguish between historical, validation,
and forecasting periods.
Create new time series variables as functions of existing time series variables.
Replace system- and user-missing values with estimates based on one of several methods.
A time series is obtained by measuring a variable (or set of variables) regularly over a period of time.
Time series data transformations assume a data file structure in which each case (row) represents a set of
observations at a different time, and the length of time between cases is uniform.
Related Topics
Create Time Series
Replace Missing Values
Seasonal Decomposition
Spectral Plots
Define Dates
Select Cases: Range
Previous Next
Define Dates
date variables,date variables,date variables
defining for time series data,defining for time series data,defining for time series data
time series data,time series data,time series data
defining date variables,defining date variables,defining date variables
The Define Dates dialog box allows you to generate date variables that can be used to establish the
periodicity of a
time series and to label output from time series analysis.
Page 23 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Cases Are. Defines the time interval used to generate dates.
Not dated removes any previously defined date variables. Any variables with the following names
are deleted: year_, quarter_, month_, week_, day_, hour_, minute_, second_, and date_.
Custom indicates the presence of custom date variables created with command syntax (for
example, a four-day work week). This item merely reflects the current state of the active dataset.
Selecting it from the list has no effect. (For information on creating custom date variables, see the
DATE command.)
First Case Is. Defines the starting date value, which is assigned to the first case. Sequential values, based
on the time interval, are assigned to subsequent cases.
Periodicity at higher level. Indicates the repetitive cyclical variation, such as the number of months in a
year or the number of days in a week. The value displayed indicates the maximum value you can enter.
A new numeric variable is created for each component that is used to define the date. The new variable
names end with an underscore. A descriptive string variable, date_, is also created from the components.
For example, if you selected Weeks, days, hours, four new variables are created: week_, day_, hour_,
and date_.
If date variables have already been defined, they are replaced when you define new date variables that
will have the same names as the existing date variables.
To Define Dates for Time Series Data
Related Topics
Time Series Data Transformations
Create Time Series
Replace Missing Values
Seasonal Decomposition
Spectral Plots
Select Cases: Range
Date Variables versus Date Format Variables
DATE
Previous Next
Date Variables versus Date Format Variables
Date variables created with Define Dates should not be confused with date format variables, defined in
the Variable view of the Data Editor. Date variables are used to establish periodicity for time series data.
Date format variables represent dates and/or times displayed in various date/time formats. Date variables
are simple integers representing the number of days, weeks, hours, and so on, from a user-specified
starting point. Internally, most date format variables are stored as the number of seconds from October
14, 1582.
Related Topics
Page 24 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Variable Names and Variable Labels in Dialog Box Lists
Data Editor
Data View
Variable View
Variable Names
Variable Measurement Level
Custom Variable Attributes
Entering Data
To Change Data Type
Copying Data Properties
Transpose
Previous Next
Create Time Series
time series data,time series data,time series data
creating new time series variables,creating new time series variables,creating new time series variables
data transformations,data transformations,data transformations
time series,time series,time series
The Create Time Series dialog box allows you to create new variables based on functions of existing
numeric time series variables. These transformed values are useful in many time series analysis
procedures.
Default new variable names are the first six characters of the existing variable used to create it, followed
by an underscore and a sequential number. For example, for the variable price, the new variable name
would be price_1. The new variables retain any defined value labels from the original variables.
Available functions for creating time series variables include differences, moving averages, running
medians, lag, and lead functions.
To Create New Time Series Variables
Related Topics
Time Series Data Transformations
Replace Missing Values
Seasonal Decomposition
Spectral Plots
Define Dates
Select Cases: Range
Time Series Transformation Functions
CREATE
Previous Next
Time Series Transformation Functions
Page 25 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
time series data,time series data,time series data
transformation functions,transformation functions,transformation functions
difference function,difference function,difference function
seasonal difference function,seasonal difference function,seasonal difference function
centered moving average function,centered moving average function,centered moving average function
prior moving average function,prior moving average function,prior moving average function
running median function,running median function,running median function
cumulative sum function,cumulative sum function,cumulative sum function
LAG (function),LAG (function),LAG (function)
lead function,lead function,lead function
smoothing function,smoothing function,smoothing function
T4253H smoothing,T4253H smoothing,T4253H smoothing
Difference. Nonseasonal difference between successive values in the series. The order is the number of
previous values used to calculate the difference. Because one observation is lost for each order of
difference, system-missing values appear at the beginning of the series. For example, if the difference
order is 2, the first two cases will have the system-missing value for the new variable.
Seasonal difference. Difference between series values a constant span apart. The span is based on the
currently defined periodicity. To compute seasonal differences, you must have defined date variables
(Data menu, Define Dates) that include a periodic component (such as months of the year). The order is
the number of seasonal periods used to compute the difference. The number of cases with the system-
missing value at the beginning of the series is equal to the periodicity multiplied by the order. For
example, if the current periodicity is 12 and the order is 2, the first 24 cases will have the system-
missing value for the new variable.
Centered moving average. Average of a span of series values surrounding and including the current
value. The span is the number of series values used to compute the average. If the span is even, the
moving average is computed by averaging each pair of uncentered means. The number of cases with the
system-missing value at the beginning and at the end of the series for a span of n is equal to n/2 for even
span values and for odd span values. For example, if the span is 5, the number of cases with the system-
missing value at the beginning and at the end of the series is 2.
Prior moving average. Average of the span of series values preceding the current value. The span is the
number of preceding series values used to compute the average. The number of cases with the system-
missing value at the beginning of the series is equal to the span value.
Running median. Median of a span of series values surrounding and including the current value. The
span is the number of series values used to compute the median. If the span is even, the median is
computed by averaging each pair of uncentered medians. The number of cases with the system-missing
value at the beginning and at the end of the series for a span of n is equal to n/2 for even span values and
for odd span values. For example, if the span is 5, the number of cases with the system-missing value at
the beginning and at the end of the series is 2.
Cumulative sum. Cumulative sum of series values up to and including the current value.
Lag. Value of a previous case, based on the specified lag order. The order is the number of cases prior to
the current case from which the value is obtained. The number of cases with the system-missing value at
the beginning of the series is equal to the order value.
Page 26 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Lead. Value of a subsequent case, based on the specified lead order. The order is the number of cases
after the current case from which the value is obtained. The number of cases with the system-missing
value at the end of the series is equal to the order value.
Smoothing. New series values based on a compound data smoother. The smoother starts with a running
median of 4, which is centered by a running median of 2. It then resmoothes these values by applying a
running median of 5, a running median of 3, and hanning (running weighted averages). Residuals are
computed by subtracting the smoothed series from the original series. This whole process is then
repeated on the computed residuals. Finally, the smoothed residuals are computed by subtracting the
smoothed values obtained the first time through the process. This is sometimes referred to as T4253H
smoothing.
Related Topics
Create Time Series
Previous Next
Replace Missing Values
missing values,missing values,missing values
replacing in time series data,replacing in time series data,replacing in time series data
time series data,time series data,time series data
replacing missing values,replacing missing values,replacing missing values
Missing observations can be problematic in analysis, and some time series measures cannot be
computed if there are missing values in the series. Sometimes the value for a particular observation is
simply not known. In addition, missing data can result from any of the following:
Each degree of differencing reduces the length of a series by 1.
Each degree of seasonal differencing reduces the length of a series by one season.
If you create new series that contain forecasts beyond the end of the existing series (by clicking a
Save button and making suitable choices), the original series and the generated residual series will
have missing data for the new observations.
Some transformations (for example, the log transformation) produce missing data for certain
values of the original series.
Missing data at the beginning or end of a series pose no particular problem; they simply shorten the
useful length of the series. Gaps in the middle of a series (embedded missing data) can be a much more
serious problem. The extent of the problem depends on the analytical procedure you are using.
The Replace Missing Values dialog box allows you to create new time series variables from existing
ones, replacing missing values with estimates computed with one of several methods. Default new
variable names are the first six characters of the existing variable used to create it, followed by an
underscore and a sequential number. For example, for the variable price, the new variable name would
be price_1. The new variables retain any defined value labels from the original variables.
To Replace Missing Values for Time Series Variables
Page 27 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Related Topics
Time Series Data Transformations
Define Dates
Create Time Series
Seasonal Decomposition
Spectral Plots
Estimation Methods for Replacing Missing Values
RMV
Previous Next
Estimation Methods for Replacing Missing
Values
replacing missing values,replacing missing values,replacing missing values
series mean,series mean,series mean
replacing missing values,replacing missing values,replacing missing values
median of nearby points,median of nearby points,median of nearby points
replacing missing values,replacing missing values,replacing missing values
mean of nearby points,mean of nearby points,mean of nearby points
replacing missing values,replacing missing values,replacing missing values
linear interpolation,linear interpolation,linear interpolation
replacing missing values,replacing missing values,replacing missing values
linear trend,linear trend,linear trend
Series mean. Replaces missing values with the mean for the entire series.
Mean of nearby points. Replaces missing values with the mean of valid surrounding values. The span of
nearby points is the number of valid values above and below the missing value used to compute the
mean.
Median of nearby points. Replaces missing values with the median of valid surrounding values. The
span of nearby points is the number of valid values above and below the missing value used to compute
the median.
Linear interpolation. Replaces missing values using a linear interpolation. The last valid value before the
missing value and the first valid value after the missing value are used for the interpolation. If the first or
last case in the series has a missing value, the missing value is not replaced.
Linear trend at point. Replaces missing values with the linear trend for that point. The existing series is
regressed on an index variable scaled 1 to n. Missing values are replaced with their predicted values.
Related Topics
Replace Missing Values
Previous Next
Page 28 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Scoring Data with Predictive Models
scoring,scoring,scoring
models supported for export and scoring,models supported for export and scoring,models supported for
export and scoring
The process of applying a predictive model to a set of data is referred to as scoring the data. SPSS,
Clementine, and AnswerTree have procedures for building predictive models such as regression,
clustering, tree, and neural network models. Once a model has been built, the model specifications can
be saved as an XML file containing all of the information necessary to reconstruct the model. The SPSS
Server product then provides the means to read an XML model file and apply the model to a dataset.
Example. A credit application is rated for risk based on various aspects of the applicant and the loan in
question. The credit score obtained from the risk model is used to accept or reject the loan application.
Scoring is treated as a transformation of the data. The model is expressed internally as a set of numeric
transformations to be applied to a given set of variables--the predictor variables specified in the model--
in order to obtain a predicted result. In this sense, the process of scoring data with a given model is
inherently the same as applying any function, such as a square root function, to a set of data.
Scoring is only available with SPSS Server and can be done interactively by users working in distributed
analysis mode. For scoring large data files you'll probably want to make use of the SPSS Batch Facility,
a separate executable version of SPSS provided with SPSS Server. For information about using the
SPSS Batch Facility, see the SPSS Batch Facility User's Guide, provided as a PDF file on the SPSS
Server product CD.
The scoring process consists of the following:
Loading a model from a file in XML (PMML) format.
Computing your scores as a new variable, using the ApplyModel or StrApplyModel function available
in the Compute Variable dialog box.
Show me
Models Supported for Export and Scoring
Related Topics
Loading a Saved Model
Displaying a List of Loaded Models
Additional Features Available with Command Syntax
Scoring Expressions (SPSS Server)
MODEL HANDLE
MODEL LIST
MODEL CLOSE
COMPUTE
Discriminant Analysis
Page 29 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
TwoStep Cluster Analysis
Linear Regression
Multinomial Logistic Regression
Logistic Regression
Creating Classification Trees
Complex Samples General Linear Model
Complex Samples Logistic Regression
Generalized Linear Models
Previous Next
Loading a Saved Model
model file,model file,model file
loading saved models to score data,loading saved models to score data,loading saved models to score
data
scoring,scoring,scoring
loading saved models,loading saved models,loading saved models
The Load Model dialog box allows you to load predictive models saved in XML (PMML) format, and is
only available when working in distributed analysis mode. Loading models is a necessary first step to
scoring data with them.
To Load a Model
Name. A name used to identify this model. The rules for valid model names are the same as for SPSS
variable names, with the addition of the $ character as an allowed first character. You will use this name
to specify the model when scoring data with the ApplyModel or StrApplyModel functions.
File. The XML (PMML) file containing the model specifications.
Missing Values
This group of options controls the treatment of missing values, encountered during the scoring process,
for the predictor variables defined in the model. A missing value in the context of scoring refers to one
of the following:
A predictor variable contains no value. For numeric variables, this means the system-missing
value. For string variables, this means a null string.
The value has been defined as user-missing, in the model, for the given predictor. Values defined
as user-missing in the active dataset, but not in the model, are not treated as missing values in the
scoring process.
The predictor variable is categorical and the value is not one of the categories defined in the
model.
Use Value Substitution. Attempt to use value substitution when scoring cases with missing values. The
method for determining a value to substitute for a missing value depends on the type of predictive
model.
Page 30 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
Show details
Use System-Missing. Return the system-missing value when scoring a case with a missing value.
Related Topics
Scoring Data with Predictive Models
Displaying a List of Loaded Models
Additional Features Available with Command Syntax
MODEL HANDLE
Previous Next
Displaying a List of Loaded Models
scoring,scoring,scoring
displaying loaded models,displaying loaded models,displaying loaded models
You can obtain a list of the currently loaded models. From the menus (only available in distributed
analysis mode) choose:
Transform
Prepare Model
List Model(s)
This will generate a Model Handles table. The table contains a list of all currently loaded models, and
includes the name (referred to as the model handle) assigned to the model, the type of model, the path to
the model file, and the method for handling missing values.
Show details
Related Topics
Scoring Data with Predictive Models
Loading a Saved Model
Additional Features Available with Command Syntax
MODEL LIST
Previous
Additional Features Available with Command
Syntax
From the Load Model dialog box, you can paste your selections into a syntax window and edit the
resulting MODEL HANDLE command syntax. This allows you to:
Map variables in the original model to different variables in the active dataset (with the MAP
Page 31 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]
subcommand). By default, the model is applied to variables in the active dataset with the same
names as the variables from the model file.
Related Topics
Scoring Data with Predictive Models
Loading a Saved Model
Displaying a List of Loaded Models
MODEL HANDLE
Page 32 of 32 Computing Variables
30/12/2008 [Link] and Settings\Admin\Local Settings\Temp\spss808\~[Link]