USING PROC_CODEBOOK.SAS - Sas Institute
USING PROC_CODEBOOK.SASKim Chantalakim_chantala@unc.eduDepartment of Health Behavior & Health EducationGillings School of Global Public HealthUNC at Chapel HillJim Terryjwterry@unc.eduCarolina Population CenterUNC at Chapel HillLast update: April 27, 2010PROC_CODEBOOK.SAS is a SAS macro program that can be used to create a comprehensive, well formatted and easy to read codebook. The program is simple to use, requiring the user to only specify one or two titles for the codebook, define the file organization, and provide a SAS data set that has labels and formats assigned to variables. Here is sample code showing how easy it is to use:*Include SAS code for variable formats, PROC_CODEBOOK macro program;%include 'C:\My_project\HWT_short_formats.sas';%include ' C:\My_project\proc_codebook.sas';*User defines folder where data set resides;libname here 'C:\My_project';*User specifies titles for codebook PDF file;title1 'CODEBOOK FOR WAY TO HEALTH BASELINE HEIGHT/WEIGHT DATA';footnote 'Created by: hwt_base_codebook.sas'; %let organization=One Record per Participant (ID); *Run Codebook macro;%proc_codebook(lib=here,file1=hwt_base, fmtlib=work.formats, pdffile=hwt_base_codebook.pdf); run;SAS Output:Detailed Instructions for using the PROC_CODEBOOK.SAS macro and creating the SAS data set are provided in the remainder of this document. RECOMMENDED REQUIREMENTS FOR THE SAS FILE TO BE DOCUMENTEDHave labels on all variables. The data set must contain at least one categorical variable and two numeric variables.Have user FORMATs assigned to all categorical variables. Standard formats should be used that assign only one value (not a list of values) or a range of values to a unique value label. No testing has been done using hybrid formats or formats with multi-value labels. Have a data set label on the SAS data file.By default, the codebook is ordered by Variable Name. See the instructions in the section “ORDERING VARIABLES IN CODEBOOK” section to control order of variables are listed in codebook.ORDERING VARIABLES IN CODEBOOKCreate a simple two variable file called work.order before you call the macro. The first variable is NAME, a 32 character field with your variable name in UPPER CASE. The second variable is ORDER, a numeric field with the order you want the variables to print. An example data step creating a work.order data set is shown below. data order; length name $ 32; name = "T1 "; ORDER = 1; OUTPUT; name = "HHID09"; ORDER = 2; OUTPUT; name = "LINE09"; ORDER = 3; OUTPUT; name = "H1D "; ORDER = 4; OUTPUT; run;TITLES AND FOOTNOTESTITLE1, TITLE2 and all FOOTNOTES are specified by user. PROC_CODEBOOK creates the following titles: TITLE4 lists the number of observations in Data set.TITLE5 lists the number of variables in the data set. TITLE6 lists the organization of the data set and is specified in a global macro variable by the user (%let organization=One Record per Participant (ID); VARIABLES SPECIFIED ON MACRO The macro is called with the following syntax:%proc_codebook(lib=libname,file1=SAS_dataset, fmtlib=work.formats, pdffile=codebook_file.pdf include_warn=NO); Required Variables: LIB = name of library for SAS data set (see FILE1 variable) used to create the codebookFILE1 = name of SAS data set used to create the codebookFMTLIB = 2-level name of format libraryPDFFILE = name of PDF file for the codebook created Optional Variables: INCLUDE_WARN= flag to control printing of WARNING messages in Codebook (in addition to printing messages in LOG file):YES=prints warnings in file specified by PDFFILE (default), NO (or Any other text)=warnings printed only in LOG file. Tips on embellishing your codebookYou can add a logo to the codebook by including a link to the logo as illustrated in the title1 statement in the following example: %let organization=One Record per ORGID*INJURY_DATE*INJURY_TYPE;ods escapechar='~';title1 j=c '~S={preimage="H:\datalys\Logo\datalys_color_logo_final.JPG"}';title2 j=l "CODEBOOK: Women's Volleyball Injury Data Set 2004-05 to 2008-09"; footnote1 j=l 'SAS data set: injwvb0409.sas7bdat';footnote2 j=l 'Created by H:\datalys\Chantala\Data Dec2009\injwvb0409.sas';footnote3 'Listed Format assignment not always stored with permanent SAS data set';%proc_codebook(lib=work,file1=injwvb0409, fmtlib=work.formats, pdffile=C:\My_project\injwvb0409_codebook.pdf,include_warn=NO);SAS Output:You can also use ODS formatting options in the title statement to control the color, height or justification of text in titles (). The following code will center and use a font of 14pt for the main title of the codebook:%let organization=One Record per ORGID*INJURY_DATE*INJURY_TYPE;title j=center height=14pt "DATALYS PROJECT CODEBOOK: Women's Volleyball Injury Data Set 2004-05 to 2008-09";ods escapechar='~';%proc_codebook(lib=work,file1=injwvb0409, fmtlib=work.formats, pdffile= C:\My_project\injwvb0409_codebook \injwvb0409_codebook.pdf,include_warn=NO);run;SAS Output:You can also use text decorations in title statements to overline and underline text. For more information see ). ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- proc reg syntax
- statistics 231b sas practice lab 1 faculty support site
- variable coding and label variables in creation order
- working with sas formats catalogs
- pc sas carnegie mellon university
- structural equation modeling
- using proc sas institute
- sas functions arithmetic functions
- using sas proc iml to generate coefficients for orthogonal
- introduction to sas