As a way of conditioning most other commands, we can use if.
For example, you may want to get descriptive statistics only for those with a specific value on a variable (or several variables). You can also e.g. generate or recode a variable given certain properties of one or more other variables.
There are simply so many things that if can be applied to, that it is impossible to do it justice with just a few examples.
More informationhelp if |
Before we get into this, however, there are something that we should address first: logical operators.
The table below presents some of the most common ones.
| Logical operators | |
| < | Less than |
| <= | Less than or equal to |
| == | Equal |
| > | Greater than |
| >= | Greater than or equal to |
| != | Not equal to |
| & | And |
| | | Or |
| ! | Not |
| () | Can be used for grouping to specify order or evaluation |