2. 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 a large variety of built-in functions, including arithmetic
functions, statistical functions, distribution functions, and string functions.
3. To Compute Variables
• From the menus choose:
– Transform > Compute Variable...
– Type the name of a single target variable. It can be an existing variable or a
new variable to be added to the active dataset.
– To build an expression, either paste components into the Expression field
or type directly in the Expression field.
– You can paste functions or commonly used system variables by selecting a
group from the Function group list and double-clicking the function or
variable in the Functions and Special Variables list (or select the function or
variable and click the arrow adjacent to the Function group list). Fill in any
parameters indicated by question marks (only applies to functions). The
function group labeled All provides a listing of all available functions and
system variables. A brief description of the currently selected function or
variable is displayed in a reserved area in the dialog box.
– String constants must be enclosed in quotation marks or apostrophes.
– If values contain decimals, a period (.) must be used as the decimal
indicator.
– For new string variables, you must also select Type & Label to specify the
data type.
4. From the menus in the Data Editor window choose:
Transform > Compute Variable...
Minus_Value1Value2= Value1-Value2
+, <,>,<=,>=,
-
*
/
6. Weigh Case
• Weight Cases gives cases different weights (by simulated replication) for
statistical analysis.
• • The values of the weighting variable should indicate the number of
observations represented by single cases in your data file.
• • Cases with zero, negative, or missing values for the weighting variable are
excluded from analysis.
• • Fractional values are valid and some procedures, such as Frequencies,
Crosstabs, and Custom Tables, will use fractional weight values. However, most
procedures treat the weighting variable as a replication weight and will simply
round fractional weights to the nearest integer. Some procedures ignore the
weighting variable completely, and this limitation is noted in the procedure-
specific documentation.
• Once you apply a weight variable, it remains in effect until you select another
weight variable or turn off weighting. If you save a weighted data file,
weighting information is saved with the data file. You can turn off weighting at
any time, even after the file has been saved in weighted form.
7. Weigh Case
• If you want to see the frequency of freq in cross tab
Analyze=>Descriptie Statistic=>
Crosstabs
Row(s):sex
Column(s):choice
25. Rank case
• The Rank Cases dialog box allows you to create new variables
containing ranks, normal and Savage scores, and percentile values
for numeric variables.
• 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. (Note: The
automatically generated new variable names are limited to a
maximum length of 8 bytes.)
• 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.