\Header{contr.SAS}{Contrast Matrices}
\keyword{design}{contr.SAS}
\keyword{regression}{contr.SAS}
\keyword{array}{contr.SAS}
\begin{Description}\relax
Return a matrix of contrasts corresponding to the parameterization for
a factor used in SAS.\end{Description}
\begin{Usage}
\begin{verbatim}
contr.SAS(n, contrasts=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{n}] a vector of levels for a factor, or the number of levels.
\item[\code{contrasts}] a logical indicating whether contrasts should be
computed.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function is used for creating contrast matrices for use in
fitting analysis of variance and regression models.  The columns of
the resulting matrix contain contrasts which can be used for coding
a factor with \code{n} levels.  The returned value contains the
computed contrasts.  If the argument \code{contrasts} is \code{FALSE}
then a square indicator matrix is returned.

These contrasts are similar to those from \code{contr.treatment}
except that they represent shifts relative to the last level of the
factor, not the first level.  This generates the same parameterization for a
linear model as is used in SAS (see \url{http://www.sas.com}).\end{Details}
\begin{Value}
A matrix with \code{n} rows and \code{k} columns, with \code{k=n-1} if
\code{contrasts} is \code{TRUE} and \code{k=n} if \code{contrasts} is
\code{FALSE}.\end{Value}
\begin{Author}\relax
Jose Pinheiro \email{jcp@research.bell-labs.com}, Douglas Bates
\email{bates@stat.wisc.edu}\end{Author}
\begin{SeeAlso}\relax
\code{\Link{contr.treatment}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
contr.SAS(4)
\end{ExampleCode}
\end{Examples}

