Transform data – Compute Variables

With MAXQDA Stats you can perform calculations on a selected variable and store the result in a new variable. To begin the calculation, select the function Transform > Compute variable from the Stats main menu. The following window will appear:

Window for calculation of new variables

When calculating variables, proceed as follows:

  1. In the upper pane of the window, assign a new variable name and a label if required. If the variable name already exists, MAXQDA will indicate it in red. The newly created variable will automatically be assigned the type “Floating”.
  2. In the lower pane “Numerical expression”, assign an evaluation instruction. If the input cannot be evaluated, for example because a bracket or a summand is missing, MAXQDA will indicate so in blue as displayed in the screenshot.

In the “Variable” section, all “Integer” and “Floating point” type variables are listed. All variables are numbered consecutively from “V1” to “Vn”, with the variable name (or the label if present) enclosed in square brackets. When proceeding with the calculation, the identifier must be inputted as displayed in the screenshot above.

Tip: Double-clicking a variable will insert it into the current cursor position, so it does not need to be entered manually.

In the right hand pane, “Functions”, frequently used functions including the applied syntax are listed. Click the function buttons to insert the function in the calculation pane.

Function

Meaning

+  -  *  /

Add, subtract, multiply, divide

^

Exponent, for example “V1^2” is the variable “V1” squared

avg(a, b, …)

Arithmetic mean of all variables or arithmetic expressions enclosed in the parentheses (separated by commas). Any number of variables or arithmetic expressions can be enclosed in the parentheses.

sum(a, b, …)

Sum of all variables or arithmetic expressions enclosed in the parentheses (separated by commas). Any number of variables or arithmetic expressions can be enclosed in the parentheses.

sqrt(a)

Root of the expression in parentheses

round(a)

The arithmetic expression in parentheses will be rounded to the next whole number

roundn(a, decimals)

The arithmetic expression in parentheses will be rounded to the specified number of decimal places

 

When you click OK, the new variable will be calculated and displayed in the Data Editor.

Hint: If one of the variable values in the calculation instruction is empty or defined as missing, a system-defined missing value will be entered for the result, and the cell will remain empty.

You can also include if-then conditions in the calculation. The following examples illustrate the syntax to be used:

if (V1 > V2) {

   V1

}

else {

   V2

}

 

Alternative Syntax:

if (V1 > V2)

   V1;

else

   V2

Was this article helpful?