Welcome to the StatRep Documentation.
The pdf documentation is the most complete; this page will get you started. See
statrepmanual.pdf
for full usage details and
statrep.pdf
for the implementation.
Installation
Complete installation instructions are included in the README and the user's manual.
If you just want a quick look to see how it works, put the files in same directory as
your LaTeX file (or use the included quickstart.tex file). As long as the *.sty files
and the statrep_macros.sas
file are in the current working directory, you
can play with the package as much as you like. Then if you decide you want to use it
for other documents, you can follow the complete installation instructions.
How it Works
When you compile your LaTeX document, the StatRep package parses your file and writes a SAS program from your code blocks and output tags. You run that program with SAS to create the actual output files. Then you compile your document again and the output files are included in the document.
Why Use It?
You can have complete confidence that the code you display in your document is the code that created the outputs, and you can recreate the outputs at any time from your LaTeX document and SAS. Your data and code reside in one LaTeX source file that you can share with others for reproducible research.
Getting Started
Assuming you have a fairly recent TeX distribution and SAS 9.2 or later installed, and
that you have installed the StatRep package, consider the LaTeX document called
quickstart.tex
; it is part of the distribution so you already have a copy.
The main parts of the file are described in the following sections.
Load the class you want and the StatRep package:
\documentclass{article} \usepackage{statrep} \title{Example and Tutorial for the StatRep Package} \author{Tim Arnold and Warren F. Kuhfeld\\SAS Institute Inc., Cary, NC} \date{April 25, 2012} \begin{document} \maketitle \section{Introduction} This article provides an example and a tutorial that show how to use the StatRep LaTeX package.
The purpose of the
Datastep
environment is to read in data.
It produces no output. Its contents are written to the generated
SAS program as-is.
\begin{Datastep} data Wine; input WineType $ VisitLength @@; datalines; white 80 white 98 white 115 white 89 white 103 white 91 white 119 white 31 white 109 white 95 white 71 white 105 white 66 white 141 white 79 white 113 white 69 white 120 white 87 red 93 red 87 red 106 red 76 red 121 red 143 red 81 red 97 red 74 red 107 red 112 red 67 red 107 red 72 red 116 red 99 red 104 red 91 red 132 red 78 red 107 red 101 red 92 ; \end{Datastep}
The purpose of the
Sascode
environment is to generate output.
You use the
store=
option so that
later in your document you can refer to output that is created in the
Sascode
environment. In this example, all output that is generated by the analysis is
stored in the ODS document
wineA
.
With no other options or commands inside the
Sascode
environment,
its contents are written to the generated SAS program as-is.
\begin{Sascode}[store=wineA] ods graphics on; proc anova data=Wine; class WineType; model VisitLength = WineType; run; ods graphics off; \end{Sascode}
The
Listing
and
Graphic
tags specify the output to be displayed.
The purpose of the
Listing
tag is to display tabular output and notes.
The purpose of the
Graphic
tag is to display graphical output.
The
Listing
tag selects three output tables from the wineA ODS document:
ClassLevels
,
NObs
, and
OverallANOVA
.
The
Graphic
tag selects the
BoxPlot
graph from the wineA ODS document.
The tags are parsed by the
StatRep
package and appropriate SAS code is written
to the generated program to write the outputs to an external file. Once the files have
been created, the tags include the outputs into the document.
\Listing[store=wineA, objects=ClassLevels NObs OverallANOVA, caption={Analysis of Variance for Visit Length}]{tsta} \Graphic[store=wineA, objects=BoxPlot, caption={Box Plots for Visit Length}]{tstb}
When you generate
the SAS program by compiling your document with pdfLaTeX,
the
StatRep
package does the following:
-
The lines in the
Datastep
environment are passed unchanged to the program. -
The lines in the
Sascode
environment are parsed for line commands and passed to the program. -
Each
Listing
tag selects the specified notes and tables. -
Each
Graphic
tag selects the specified graphs.
When you execute the generated SAS program, the output that is
specified in the
Listing
and
Graphic
tags is automatically captured.
When you recompile your document, the
Listing
and
Graphic
tags
insert the requested SAS results and page breaks are handled automatically.