This article is part of The Definitive Guide to Importing and Preparing Data.
There could be a time when you want to cap a numeric variable at a certain amount, perhaps to remove the effect of outliers. For example, on a numeric question, there is a distribution of values where the majority are in the range of 0 to 500, but there are some above 500, even going into the 1000s which are skewing your results. You can create a new variable that sets the maximum value as 500, effectively changing everything larger than 500 to 500.
In the web app
- Capping numeric variables is not currently available in the web app.
Crunch Automation
The best way to achieve the capping of a numeric variable is by deriving a new numeric case variable. This method will keep your original source variable intact, though it can be hidden from the Variable Sidebar. Since the new variable is a derivation of a source variable, its values will update if you add more rows to the dataset (e.g., such as in the context of a tracking study).
The following example takes a numeric variable (num) and caps it at a value of 10.
CREATE NUMERIC CASE
WHEN num > 10 THEN 10
ELSE VARIABLE num
END
AS num_capped
TITLE "Num Capped";