1. Home
2. Subset by Matching Conditions

# Subset by Matching Conditions

If you want to store a subset of the units in a vector rather than restricting the original data set, you can use the Subset menu. This method forms a vector containing a subset of the values from another vector. You can form a subset for either a variate, factor or text. The subset is defined by a logical condition, which is specified by the matching conditions where units with the value TRUE (neither zero nor missing value) for the condition are included in the subset: others are omitted.

1. From the menu select Data | Subset.
The Available data field lists variates, factors and texts which are available to form a subset from.

2. In the Available data field, double-click the items you want to move to the Data to subset field.
3. Type a name for your subset.
4. Enter the logical condition that you want to use to subset your data.
You can combine expressions by chaining them together in the first field, or select And or Or and input another expression into the lower field.
You are not restricted to the logical operators in the Comparisons field, but can build your own condition using standard logical functions.
5. Click Run to create the subset.The subset is now available for analysis and can be seen in the Data View by clicking the Data tab at the bottom left of the window.
6. To view the subset as a spreadsheet, in the Data View, click and drag your subset over any open spreadsheet then release.

This creates a new spreadsheet containing only your subset. You can now save it or run an analysis on it.

 Matching condition Input your conditions into one or both fields. You can combine expressions by chaining them together in the first field, or select And or Or and input another expression into the lower field. For example, the expression below, which has And selected, will select all rows belonging to month 4, 5 or 6 in the year 2017. Create expression Click this to open the Form Expression dialog, which contains more logical operators to help build your restriction.
Building logical expressions

Logical operators must be delimited by dots (.and. .or. .not.)
Strings must be enclosed in quotes (‘Control’, ‘Once’, ‘Twice’.)

Example
Match all rows where the column Drench has a value of Once or Twice, and the Lwt2 column has a value greater than 50:
Drench .in. ‘Once’ .or. Drench .in. ‘Twice’ .and. Lwt2>50

You are not restricted to the logical operators in the Comparisons field, but can build your own condition using standard logical functions.

Example
Match all rows where the difference in value between Lwt1 and Lwt2 is greater than 15:
(Lwt2-Lwt1)>15

Updated on March 1, 2019