The TTEST Procedure
PROC TTEST Statement
PROC TTEST <options>;
The PROC TTEST statement invokes the TTEST procedure. Table 121.2 summarizes the options available in the PROC TTEST statement. The options are then described fully in alphabetical order.
Table 121.2: PROC TTEST Statement Options
Option | Description |
|---|---|
Basic Options | |
Specifies input data set | |
Determines sort order of CLASS variable or CROSSOVER= treatment variables | |
Analysis Options | |
Specifies 1 – confidence level | |
Specifies distributional assumption (normal or lognormal) | |
Specifies null value | |
Specifies number of sides and direction | |
Specifies test criterion (difference or ratio) | |
Requests equivalence test and specifies bounds | |
Displayed Output | |
Requests confidence interval for standard deviation or coefficient of variation | |
Requests Cochran t test | |
Produces ODS statistical graphics | |
Output Ordering | |
Groups results by variables that are specified in the PAIRED or VAR statement | |
Groups results by tables | |
You can specify the following options:
- ALPHA=p
specifies that confidence intervals (except test-based mean confidence intervals when the TOST option is used) are to be 100(1 – p)% confidence intervals, where 0 < p < 1. When the TOST option is used, the test-based mean confidence intervals are 100(1 – 2p)% confidence intervals. If p is 0 or less, or 1 or more, an error message is printed. By default, ALPHA=0.05.
- BYVAR
groups the results by the variables that are specified in the PAIRED or VAR statement. The BYVAR option is enabled by default. Note that this represents a change from previous releases for how the results are grouped with respect to variables and tables. Prior to SAS 9.2, multiple variables were included in each table, similar to the new NOBYVAR option.
-
CI=EQUAL | UMPU | NONE
CL=EQUAL | UMPU | NONE specifies whether a confidence interval is displayed for and, if so, what kind. You can specify one or more of the following values:
The values EQUAL and UMPU together request that both types of confidence intervals be displayed. If the value NONE is specified with one or both of the values EQUAL and UMPU, NONE takes precedence. For more information, see the section Two-Independent-Sample Design. By default, CI=EQUAL.
- COCHRAN
requests the Cochran and Cox (1950) approximation of the probability level for the unequal variances situation. For more information, see the section Two-Independent-Sample Design.
- DATA=SAS-data-set
names the SAS data set for the procedure to use. By default, PROC TTEST uses the most recently created SAS data set. The input data set can contain summary statistics of the observations instead of the observations themselves. The number, mean, and standard deviation of the observations are required for each BY group (one sample and paired differences) or for each class within each BY group (two samples). For more information about the DATA= option, see the section Input Data Set of Statistics.
- DIST=LOGNORMAL | NORMAL
specifies the underlying distribution assumed for the data. You can specify the following values:
- LOGNORMAL
specifies that the underlying distribution is lognormal.
- NORMAL
specifies that the underlying distribution is normal.
By default, DIST=NORMAL, unless TEST=RATIO is specified, in which case the default is DIST=LOGNORMAL.
- H0=m
requests tests against a null value of m, unless the TOST option is used, in which case m is merely used to derive the lower and upper equivalence bounds. For the crossover design, the value m applies for both treatment and period tests. By default, H0=0 when TEST=DIFF (or DIST=NORMAL for a one-sample design) and H0=1 when TEST=RATIO (or DIST=LOGNORMAL for a one-sample design).
- NOBYVAR
includes all variables that are specified in the PAIRED or VAR statement together in each output table. If the NOBYVAR option is not specified, then the BYVAR option is enabled, grouping the results by the PAIRED and VAR variables.
- ORDER=DATA | FORMATTED | FREQ | INTERNAL | MIXED
specifies the order in which to sort the levels of the classification variables (which are specified in the CLASS statement) and treatment variables (which are specified in the CROSSOVER= option in the VAR statement).
This option applies to the levels for all classification or treatment variables, except when you use the ORDER=FORMATTED option with numeric classification or treatment variables that have no explicit format. With this option, the levels of such variables are ordered by their internal value.
You can specify the following values:
Table 121.3: continued
Value of ORDER=
Levels Sorted By
DATA
Order of appearance in the input data set.
FORMATTED
External formatted value, except for numeric variables that have no explicit format, which are sorted by their unformatted (internal) value. The sort order is machine-dependent.
FREQ
Descending frequency count; levels that have the greatest number of observations come first in the order. In the event of a tie, ORDER=MIXED is used.
INTERNAL
Unformatted value. The sort order is machine-dependent.
MIXED
Same as ORDER=FORMATTED if the unformatted variable is character-valued; same as ORDER=INTERNAL otherwise (the unformatted variable is numeric-valued).
For FORMATTED and INTERNAL, the sort order is machine-dependent.
For more information about sort order, see the chapter on the SORT procedure in the Base SAS Procedures Guide and the discussion of BY-group processing in SAS Language Reference: Concepts.
By default, ORDER=MIXED, which corresponds to the ordering in releases previous to SAS 9.2.
-
PLOTS <(global-plot-options)> <= plot-request<(options)>>
PLOTS <(global-plot-options)> <= (plot-request<(options)> <... plot-request<(options)>>)> controls the plots produced through ODS Graphics. When you specify only one plot-request, you can omit the parentheses around the plot-request. Here are some examples:
plots=none plots=(histogram boxplot interval qq profiles agreement) plots(unpack)=summary plots(showh0)=interval(type=pergroup) plots=(summary(unpack) interval(type=period))
ODS Graphics must be enabled before plots can be requested. For example:
ods graphics on; proc ttest plots=all; var oxygen; run; ods graphics off;
For more information about enabling and disabling ODS Graphics, see the section Enabling and Disabling ODS Graphics in Chapter 21: Statistical Graphics Using ODS.
If ODS Graphics is enabled but you do not specify the PLOTS option, then PROC TTEST produces a default set of plots. ( Note: The graphical results are unavailable if your input data set contains summary statistics rather than observation values.)
For a one-sample design, the default plots are the following:
summary plot (histogram with overlaid normal and kernel densities, box plot, and confidence interval band)
Q-Q plot
For a two-independent-sample design, the default plots are the following:
summary plot (comparative histograms with overlaid densities and box plots)
Q-Q plot
For a paired design, the default plots are the following:
summary plot (histogram, densities, box plot, and confidence interval) of the difference or ratio
Q-Q plot of the difference or ratio
profiles plot
agreement plot
For a crossover design, the default plots are the following:
comparative histograms with overlaid densities by treatment and period
comparative box plots by treatment and period
Q-Q plots by treatment and period
profiles over treatment plot
agreement of treatments plot
For more detailed descriptions of plots, see the section Interpreting Graphs.
You can specify the following global-plot-options:
- ONLY
suppresses the default plots. Only plots that are specifically requested are displayed.
-
SHOWH0
SHOWNULL shows the null value (as specified by the H0= option in the PROC TTEST statement) in all relevant plots. For one-sample and paired designs, the null value can appear when you also specify the SUMMARY, BOX, or INTERVAL plot-request. For two-independent-sample and crossover designs, the null value can appear only when you specify the INTERVAL plot-request.
-
UNPACKPANEL
UNPACK suppresses paneling. By default, multiple plots can appear in some output panels. Specify UNPACKPANEL to get each plot in a separate panel. You can specify PLOTS(UNPACKPANEL) to unpack the default plots.
You can specify the following plot-requests:
- ALL
produces all appropriate plots. You can specify other plot-requests with ALL; for example, to request all plots and specify that intervals should be for the period difference in a crossover design, specify PLOTS=(ALL INTERVAL(TYPE=PERIOD)).
-
AGREEMENT <TYPE=type>
AGREEMENTPLOT <TYPE=type> requests an agreement plot. This plot is produced by default for paired and crossover designs, the only designs for which the AGREEMENT option is valid.
For paired designs, the second response in each pair is plotted against the first response. For more information, see the section Agreement Plots for Paired Designs.
For crossover designs, you can specify the following options:
- TYPE=PERIOD
plots the response in the second period against the response in the first period. For more information, see the section Period Agreement Plots for Crossover Designs.
- TYPE=TREATMENT
plots the response associated with the second treatment against the response associated with the first treatment. For more information, see the section Treatment Agreement Plots for Crossover Designs.
By default, TYPE=TREATMENT for crossover designs.
-
BOX
BOXPLOT requests a box plot or comparative box plots. A box plot is produced by default for crossover designs. For other designs, a box plot appears by default if you specify the SUMMARY or ALL plot-request.
For one-sample and paired designs, a confidence interval for the mean is shown as a band in the background, along with the equivalence bounds if the TOST option is used in the PROC TTEST statement.
For a two-independent-sample design, comparative box plots (one for each class) are shown. For a crossover design, comparative box plots for all four combinations of the two treatments and two periods are shown.
For more information, see the section Box Plots.
-
HISTOGRAM
HIST
HISTDENS requests a histogram or comparative histograms along with overlaid normal and kernel densities. A histogram is produced by default for crossover designs. For other designs, it appears by default if you specify the SUMMARY or ALL plot-request.
For one-sample and paired designs, the histogram and densities are based on the test criterion (which is the mean difference or ratio for a paired design). For a two-independent-sample design, comparative histograms (one for each class) are shown. For a crossover design, histograms for all four combinations of the two treatments and two periods are shown.
For more information, see the section Histograms.
-
INTERVAL <TYPE=type>
INTERVALPLOT <TYPE=type> requests plots of confidence interval for means.
For a two-independent-sample design, you can specify one of the following options:
- TYPE=PERGROUP
shows two separate two-sided confidence intervals, one for each class. This option cannot be used along with the SHOWH0 global plot option.
- TYPE=TEST
shows pooled and Satterthwaite confidence intervals.
By default, TYPE=TEST for two-independent-sample designs.
For a crossover design, you can specify the following options:
- TYPE=PERGROUP
shows four separate two-sided intervals, one for each treatment-by-period combination. This option cannot be used along with the SHOWH0 global plot option.
- TYPE=PERIOD
shows pooled and Satterthwaite confidence intervals for the period difference or ratio. This option is invalid if the IGNOREPERIOD option is used in the VAR statement.
- TYPE=TREATMENT
shows pooled and Satterthwaite confidence intervals for the treatment difference or ratio.
By default, TYPE=TREATMENT for crossover designs.
For more information, see the section Confidence Intervals.
- NONE
suppresses all plots.
-
PROFILES <TYPE=type>
PROFILESPLOT <TYPE=type> requests a profiles plot. This plot is produced by default for paired and crossover designs, the only designs for which the PROFILES option is valid.
For paired designs, a line is drawn for each observation from left to right connecting the first response to the second response. For more information, see the section Profiles for Paired Designs.
For crossover designs, you can specify one of the following options:
- TYPE=PERIOD
shows response profiles over period, connecting the first period on the left to the second period on the right for each subject. For more information, see the section Profiles over Period for Crossover Designs.
- TYPE=TREATMENT
shows response profiles over treatment values, connecting the first treatment on the left to the second treatment on the right for each observation. For more information, see the section Profiles over Treatment for Crossover Designs.
By default, TYPE=TREATMENT for crossover designs.
-
QQ
QQPLOT requests a normal quantile-quantile (Q-Q) plot. This plot is produced by default for all designs.
For two-sample designs, separate plots are shown for each class in a single panel. For crossover design, separate plots are shown for each treatment-by-period combination in a single panel.
For more information, see the section Q-Q Plots.
-
SUMMARY <UNPACK>
SUMMARYPLOT <UNPACK> requests HISTOGRAM and BOX plots together in a single panel, sharing common X axes. These plots are produced by default for one-sample, paired, and two-independent-sample designs, the only designs for which the SUMMARY option is valid. For more information, see the documentation for the BOX and HISTOGRAM plot-requests. You can specify the following option:
-
SIDES=2 | L | U
SIDED=2 | L | U
SIDE=2 | L | U specifies the number of sides (or tails) and direction of the statistical tests and test-based confidence intervals. The values are interpreted as follows:
- 2
specifies two-sided tests and confidence intervals for means.
- L
specifies lower one-sided tests (in which the alternative hypothesis indicates a mean less than the null value) and lower one-sided confidence intervals between minus infinity and the upper confidence limit.
- U
specifies upper one-sided tests (in which the alternative hypothesis indicates a mean greater than the null value) and upper one-sided confidence intervals between the lower confidence limit and infinity.
By default, SIDES=2.
- TEST=DIFF | RATIO
specifies the test criterion. This option is ignored for one-sample designs. You can specify the following values:
- DIFF
tests the difference of means.
- RATIO
tests the ratio of means.
By default, TEST=DIFF, unless DIST=LOGNORMAL is specified, in which case the default is TEST=RATIO.
- TOST ( <lower ,> upper )
requests Schuirmann’s TOST equivalence test. The upper equivalence bound must be specified. If TEST=DIFF, then the default value for the lower equivalence bound is upper, where m is the value of the H0= option. If TEST=RATIO, then the default value for lower is m / upper.
Copyright © SAS Institute Inc. All rights reserved.