Overview
Codebooks can be generated using a simple call to a SAS macro.
SAS
%*--- example codebook macro call ---;
%codebook
(file=derive.adsl
,formats=library
);
Codebooks can be generated using a simple call to a SAS macro.
SAS
%*--- example codebook macro call ---;
%codebook
(file=derive.adsl
,formats=library
);
Because R and MikTeX programs and packages have already been installed to the Rho network, creating a codebook at Rho is straightforward. The SAS macro lives at
I:\RHO_APPS\Codebooks
Simply %include the codebook.sas macro from this location and you're off to the races. See the Sample Code section below for two typical uses of the codebook macro.
Using the codebook macro outside of the Rho network requires a little more work. Instructions for use of the macro outside of the Rho network are provided below.
The SAS macro utilizes R and MikTeX (a relation of LaTeX) to produce the output in PDF format. In order to use the codebook macro you must have all 3 pieces of software installed on your computer. We assume you already have SAS installed on your machine. To get R and MikTeX on your machine:
In the macro codebook.sas, modify the default values for the parameters PDFLATEX, REXE, RSOURCE, SWEAVE, and RLIBRARY to fit your local setup. Your paths will vary depending on exactly where you decide to save/install the programs and folders downloaded in the previous steps. Example file paths from a recent local install
Having performed the above setup steps, you are now ready to use the SAS macro. The simplest call to the macro requires only the name of a dataset (e.g., FILE=derive.adsl). It is also helpful, though not required, to specify the libname associated with the format catalog for the study (e.g., FORMATS=library).
It is also possible to generate multiple codebooks at once. This can be done in one of two ways.
Various other optional parameters exist. The interested reader can find additional information in the macro header block.
SAS
*------------------------------------------------------------;
*---------- define dataset and format libnames ----------;
*------------------------------------------------------------;
libname derive "_some_path_" access=readonly;
libname library "_some_path_" access=readonly;
*------------------------------------------------------------;
*---------- macro invocation ----------;
*------------------------------------------------------------;
%include "_some_path_\codebook.sas";1
*---------- generate a code book for one dataset ----------;
%codebook
(file=derive.adsl
,formats=library
);2
*---------- generate code books for an entire library ----------;
%codebook
(libref=derive
,formats=library
);3
1 See above for macro download links.
2 The macro creates pdf file ADSL.pdf. By default the pdf is saved in the same directory as the calling program. Use optional parameter PDFLOC to specify an alternate saving location.
3 The macro creates one pdf file corresponding to every dataset in the DERIVE library. The pdf files are named after the datasets (e.g., dataset ADCM will generate ADCM.pdf).