See Crunch Automation basics for more information.

The CREATE NUMERIC command allows you to create a numeric variable from an arithmetic numeric expression.

The CREATE NUMERIC command allows you to create a numeric variable from an arithmetic numeric expression. You can use any numeric or categorical variables in your numeric expression.

*Numeric expressions* differ from *boolean expressions* (see the Expressions section of Crunch Automation basics article). Boolean expressions are evaluated as either true or false (i.e., missing) and are used in LOGICAL, CATEGORICAL CASE, and NUMERIC CASE commands. You may use parentheses in numeric expressions to indicate the order of operations.

Numeric expressions must evaluate to a numeric result. Logical values of true and false are distinct, and are *not* cast to numeric '1' and '0'.

CREATE commands create a new derived variable, which will automatically reflect any changes in the source variable. For example, if you remove the numeric values from a categorical variable that is used in a numeric expression, then the resulting numeric variable will evaluate to missing for all cases.

```
CREATE NUMERIC
expression
AS alias
[TITLE "string"]
[DESCRIPTION "string"]
[NOTES "string"];
```

## Use cases

The following three examples are described in this section:

**Summing variables**— to get a total number of items purchased**Computing the difference between two variables**— to average the values on a scale**Calculating age from the year of birth**

### Summing variables

Suppose we have three numeric variables that store how many bottles of wine a respondent purchased. Respondents would have a numeric input field to capture the exact number of bottles they bought. There are three different input fields:

- Red wine (winepurchase_red)
- White wine (winepurchase_white)
- Other wine (winepurchase_other)

Use the following Crunch Automation command to create a total variable to find out what is the total number of wine bottles bought per respondent:

```
CREATE NUMERIC
Winepurchase_red + winepurchase_red + winepurchase_other
AS winepurchase_total
TITLE "Total wines purchased"
DESCRIPTION "Calculated as a sum of red, white, and other";
```

### Computing the difference between two variables

Suppose respondents rated their sentiment (on a 0 to 10 scale) they feel about a brand before and after being exposed to an advertising message for it. Both the pre and post variables are stored as categorical variables, and have numeric values assigned to each category (0 - 10, respectively). We want to calculate the difference between post and pre, as a means of evaluating the impact of the exposure to the advertisment:

```
CREATE NUMERIC
ad_post - ad_pre
AS ad_diff
TITLE "Change in brand sentiment"
DESCRIPTION “Average of the change for each respondents between post and pre exposure to the ad ”;
```

### Calculating age from the year of birth

Suppose respondents inputted their year of birth with a numeric input field (e.g., a dropdown). You want to calculate their age (as best you can) from the year of birth (variable alias birthyear).

In the following, we use Crunch Automation to calculate the year of birth from the current year (2020 being the year at the time of writing this article):

```
CREATE NUMERIC
(2020 - birthyear)
AS age
TITLE "Age"
DESCRIPTION "Calculated from birth year";
```

- If you’re looking to cap a numeric variable, or remove outliers, you can consider using CREATE NUMERIC CASE.
- If you want to ‘bin’ a numeric variable into categories, first use the command CREATE CATEGORICAL CUT and then use the above command.