Using Proc Codebook.Sas

Using Proc Codebook.Sas

<p> USING PROC_CODEBOOK.SAS</p><p>Kim Chantala [email protected] Department of Health Behavior & Health Education Gillings School of Global Public Health UNC at Chapel Hill</p><p>Jim Terry [email protected] Carolina Population Center UNC at Chapel Hill</p><p>Last update: April 27, 2010</p><p>PROC_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:</p><p>*Include SAS code for variable formats, PROC_CODEBOOK macro program;</p><p>%include 'C:\My_project\HWT_short_formats.sas'; %include ' C:\My_project\proc_codebook.sas';</p><p>*User defines folder where data set resides; libname here 'C:\My_project';</p><p>*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); </p><p>*Run Codebook macro;</p><p>%proc_codebook(lib=here, file1=hwt_base, fmtlib=work.formats, pdffile=hwt_base_codebook.pdf); run;</p><p>1 SAS Output:</p><p>Detailed Instructions for using the PROC_CODEBOOK.SAS macro and creating the SAS data set are provided in the remainder of this document. </p><p>RECOMMENDED REQUIREMENTS FOR THE SAS FILE TO BE DOCUMENTED  Have 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.</p><p>2 ORDERING VARIABLES IN CODEBOOK Create 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.</p><p> 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;</p><p>TITLES AND FOOTNOTES TITLE1, 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); </p><p>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); </p><p>Required Variables:  LIB = name of library for SAS data set (see FILE1 variable) used to create the codebook  FILE1 = name of SAS data set used to create the codebook  FMTLIB = 2-level name of format library  PDFFILE = name of PDF file for the codebook created</p><p>Optional Variables:  INCLUDE_WARN= flag to control printing of WARNING messages in Codebook (in addition to printing messages in LOG file): o YES=prints warnings in file specified by PDFFILE (default), o NO (or Any other text)=warnings printed only in LOG file. </p><p>3 Tips on embellishing your codebook</p><p>You can add a logo to the codebook by including a link to the logo as illustrated in the title1 statement in the following example: </p><p>%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);</p><p>4 SAS Output:</p><p>You can also use ODS formatting options in the title statement to control the color, height or justification of text in titles (http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000220968.htm). The following code will center and use a font of 14pt for the main title of the codebook:</p><p>%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);</p><p>5 run;</p><p>SAS Output:</p><p>You can also use text decorations in title statements to overline and underline text. For more information see http://support.sas.com/rnd/base/new92/92pdf.html ).</p><p>6</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us