Spreadsheet Formulas - Overview

When you enter a long variable name (in the Long name field in the Variable dialog box) that starts with an equal sign, Statistica assumes that it is a formula and verifies it for formal correctness.

If the formula is formally correct, you are then given the choice to recalculate the variable now or later.

You can use variable formulas to perform these tasks:

  • Verify data
  • Transform a variable
  • Recode a variable
  • Create values of the variable based on logical conditions (such as =(v0<=100)*1 + (v0>100)*2 assigns a value of 1 to cases number 1 through 100 and 2 to cases above 100).

 Refer to variables by their names (such as Test1, Income) or numbers (such as v1, v2, v3, ...); v0 is the case number. A comment might be added to a formula following a semicolon.

Examples:

Formula Result
=(v1+v2+v3)/3 Computes the average of the first 3 variables
=(v0<=10)*1+(v0>10)*2 Recodes cases 1-10 as 1, rest as 2
=vnormal(rnd(1),50,3) Generates random numbers from a Normal distribution (m=50,s=3)
  1. Click the Functions button in this dialog box in order to open the Function Wizard dialog box.
  2. From this dialog box, you can choose the desired part of the formula (such as an operator, distribution, or math function).
  3. When you click OK in this dialog box, the selection is pasted in the current cursor position in the edit field.

See also: Spreadsheet Formulas - Syntax Summary, Spreadsheet Formulas - Distributions and their functions, Spreadsheet Formulas - Examples, Spreadsheet Formulas - Predefined Functions.

For details on how missing data values are handled in arithmetic and logical expressions (such as in case selection conditions, spreadsheet formulas), see Logical and arithmetic expressions involving missing data values always evaluate to FALSE or Missing Data.