A simple example of a statistical analysis using SASweave

The document is essentially written in LaTeX with SAS code inserted along the way in a special environment. The file is saved with an .SAStex extension.

\documentclass{amsart}
\documentclass{amsart}
\title{Simple SASweave usage example:\\ Analysis of Fisher's iris data}
\author{BERD Reproducible Research working group}
\date{}
\SASweaveOpts{outputsize=\footnotesize, echo=false}

\begin{document}
\maketitle

The famous (Fisher's or Anderson's) iris data set gives the measurements in centimeters of the variables
sepal length and width, and petal length and width, respectively, for 50 flowers from each of
3 species of iris.  The species are \emph{setosa, versicolor, virginica}.

First, let's run a simple ANOVA comparing the sepal lengths of the three species.
\begin{SAScode}
  PROC ANOVA DATA=sashelp.iris;
    ODS SELECT OverallANOVA;
    CLASS Species;
    MODEL SepalLength = Species;
  RUN;
\end{SAScode}

We can see that the three species have significantly different sepal lengths.  Figure~\ref{F:box} shows the corresponding
boxplot.

\begin{figure}
\begin{SAScode}{sgfig=1}
  PROC SGPLOT DATA=sashelp.iris;
    VBOX SepalLength / CATEGORY=Species;
  RUN;
\end{SAScode}
\caption{Boxplot of sepal lengths by species.}\label{F:box}
\end{figure}
\end{document}
This file can be compiled from a terminal window by calling

sasweave iris.SAStex   

This produces the following PDF file .

-- AnikoSzabo - 30 Dec 2010



Topic attachments
I Attachment Action Size Date Who Comment
iris.SAStexSAStex iris.SAStex manage 1 K 30 Dec 2010 - 21:32 UnknownUser SASweave script
iris.pdfpdf iris.pdf manage 150 K 30 Dec 2010 - 21:32 UnknownUser PDF file created by SASweave