Previous PageNext Page

Example 4: Statistical Functions
There are a number of statistical functions (for example: mean, standard deviation, sum) that operate on variables and calculate the desired result. Consider:
Data NewTest;
Set OldTest;
Score = Mean (Item1, Item2, Item3, Item4, Item5,
Item6, Item7, Item8, Item9, Item10);
Run;
Which you might be tempted to do as:
Data NewTest;
Set OldTest;
Score = Mean (Item1-Item10); *WRONG;
Run;
If you are going to use the single dash abbreviation in a function call you must make add "OF" before the abbreviation.
Data NewTest;
Set OldTest;
Score = Mean (OF Item1-Item10);
Run;
Another tempting possibility:
Data NewTest;
Set OldTest;
Score = (Item1+Item2+Item3+Item4+Item5+
Item6+Item7+Item8+Item9+Item10) / 10;
Run;
This last example will produce the same - correct - result as long as none of the items are missing. If at least one item is missing, then SCORE will also be missing.

Previous PageTable Of ContentsNext Page