PROC DOC III: Self-generating Codebooks Using SAS®

Slides:



Advertisements
Similar presentations
Quantitative Data Preparation Louise Corti ESDS/ UKDA Social Science Data Archives for Social Historians: creating, depositing and using qualitative data.
Advertisements

Quantitative Data Preparation Alasdair Crockett, Data Services Manager UK Data Archive.
Microsoft ® Office 2007 Training Security II: Turn off the Message Bar and run code safely P J Human Resources Pte Ltd presents:
The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
Stat-JR: eBooks Richard Parker. Quick overview To recap… Stat-JR uses templates to perform specific functions on datasets, e.g.: – 1LevelMod fits 1-level.
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
XP Introduction1 Succeeding in Business Applications with MS Office 2003 Introduction to Problem Solving with Microsoft Office 2003 “You’ve got to seize.
07/19/04 NorCal OAUG Training Day, Paper 2.4 John Peters, JRPJR, Inc.1 Oracle Workflow Notifications John Peters JRPJR, Inc.
FORMAT FESTIVAL AN INTRODUCTION TO SAS® FORMATS AND INFORMATS By David Maddox.
IPUMS to IHSN: Leveraging structured metadata for discovering multi-national census and survey data Wendy L. Thomas 4 th Conference of the European Survey.
Wizards, Templates, Styles & Macros Chapter 3. Contents This presentation covers the following: – Purpose, Characteristics, Advantages and Disadvantages.
Copyright © 2010, Meta-Xceed, Inc. All rights reserved. BI Flash and all other Meta-Xceed Inc. product or service names are registered trademarks or trademarks.
SAS Macros ® 101 How I learned to stop worrying and love macros Alex Chaplin BCS USA Section.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.
My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga.
Multiple Uses for a Simple SQL Procedure Rebecca Larsen University of South Florida.
%rtf2data: A utility macro to convert RTF Table to SAS® dataset
Copyright © 2005, SAS Institute Inc. All rights reserved. SAS is a registered trademark or trademark of SAS Institute Inc. in the USA and other countries.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
The Purrfectly Fabulous Feline Functions Prepared by Louise Hadden Abt Associates Inc. April 2010.
Use SAS to Automate Hospital Reports generation Cardiac Service BC Stats Team, PHSA Tina Yang.
Virginia Administrative Training Module 1: Processing, Online, Scoring and Reporting Training Presentation Training Presentation Working Within PearsonAccess.
Copyright © SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
Build your Metadata with PROC CONTENTS and ODS OUTPUT Louise S. Hadden Abt Associates Inc.
Better Metadata Through SAS® II: %SYSFUNC, PROC DATASETS, and Dictionary Tables.
1 Terminal Management System Usage Overview Document Version 1.1.
ABSTRACT This is the template for preparing posters for the Electrical Safety Workshop (ESW). It is intended to define the required format for printing.
A Digital Literacy Program
Presenting Author, Co-Author Name, PI Name, Dept
Chapter 11 Reading SAS Data
User-Written Functions
Public Key Infrastructure (PKI)
To the ETS – Accounts Setup and Preferences Online Training Course
Greg Steffens Noumena Solutions
Poster Title Author #1 name, ABC Corporation, City, Country Author #2 name, ABC Corporation, City, Country Abstract A brief abstract at the beginning summarizes.
A brief introduction to the topic
Presentation Title Your Name
Chapter 2: Getting Data into SAS
Remark Test Grading Cloud: A Primer
Introduction to WRDS data platform
Intro to PHP & Variables
Introduction to the MS Word template for IEEE standards drafts
Poster Title Author #1 name, ABC Corporation, City, Country Author #2 name, ABC Corporation, City, Country Abstract A brief abstract at the beginning summarizes.
Visual Solution to Room Usage Reporting
SAS and all other SAS Institute Inc
Introduction to SAS A SAS program is a list of SAS statements executed in order Every SAS statement ends with a semicolon! SAS statements can be in caps.
Beautiful PROC CONTENTS Output Using the ODS Excel Destination
Programming in JavaScript
Data Management – Documentation
Architecture + system-based How to assign passwords
INFORMATION TECHNOLOGY NEW USER ORIENTATION
Introduction to DATA Step Programming: SAS Basics II
Louise S. Hadden, Lead Programmer Analyst, Abt Associates Inc.
Junior College Prep 5/17/18.
INFORMATION TECHNOLOGY NEW USER ORIENTATION
A Macro Tool to Find and/or Split Variable Text String Greater Than 200 Characters for Regulatory Submission Datasets. Venkata N Madhira Senior Statistical.
Writing an Engineering Report (Formal Reports)
Programming in JavaScript
Automate Repetitive Programming Tasks: Effective SAS® Code Generators
Automating SAS through the Power of VB Script
To the ETS – Accounts Setup and Preferences Online Training Course
TOWN OF PALM BEACH ELECTRONIC SOLICITATION SYSTEM
Author: Kaiqing Fan Company: Mastech Digital Inc.
Welcome 1 This is a document to explains the chosen concept to the animator. This will take you through a 5 section process to provide the necessary details.
TOWN OF PALM BEACH ELECTRONIC SOLICITATION SYSTEM
Presentation transcript:

PROC DOC III: Self-generating Codebooks Using SAS® Ms. Hadden has been using and loving SAS since the days of punch cards and computers the size of a “tiny house.” She spends most of her time in support of health policy analytics at Abt Associates Inc. and loves a good SAS reporting challenge. I am an ardent life long learner and reads voraciously, loves photography and volunteers at the MSPCA Boston Adoption Center walking, training and photographing dogs. PharmaSUG 2017 Paper #QT07

Introduction This paper will demonstrate how to use good documentation practices and SAS® to easily produce attractive, camera-ready data codebooks (and accompanying materials such as label statements, format assignment statements, etc.) We’ll go briefly through the process, concepts first, then step by step. More details are included in the paper.

What is a SAS® Program? At the highest level, it is SOFTWARE A set of instructions At the most basic level, it is a TEXT FILE Troy Martin Hughes will tell you it is software -

What does SAS do with text files? From within a SAS program: Reads, as in input files and include files Writes, as in output files Executes instructions SAS can read all types of “text” files – flag, csv, html, etc. Similarly, SAS can write all types of “text” files, and can use include files that have been created within the same program (prior to inclusion of course).

Codebook program overview We read metadata and execute instructions in the text file (program) We write out text files of SAS instructions We write out text %include files We read (and %include) text files of SAS instructions We write out output files This program for generating a codebook covers many uses of text files in SAS – it does not include “control” files, for example.

First steps Create a modified copy of SASHELP.HEART Create a documentation spreadsheet of PROC CONTENTS output (PROC EXPORT) Review spreadsheet and modify if needed In real life, we assume you’ve practiced good documentation and coding – have labeled your data sets, variables and created formats. For our example, we used SASHELP.HEART. Although it’s not strictly necessary, I have added this step just to emphasize that. Copy – add a couple of variables, a data set label, and variable labels Create – we could use PROC DATASETS, dictionary tables, sashelp.vcolumn, or PROC CONTENTS among others. I use PC because of sort var names among other things – output objects are the best Review – your boss may want to redo labels, or categorize variables. For example, there may be privacy concerns with IDs.

First steps Copy – add a couple of variables, a data set label, and variable labels Create – we could use PROC DATASETS, dictionary tables, sashelp.vcolumn, or PROC CONTENTS among others. I use PC because of sort var names among other things – output objects are the best Review – your boss may want to redo labels, or categorize variables. For example, there may be privacy concerns with IDs.

Second steps Import modified spreadsheet (PROC IMPORT) Use data from modified spreadsheet to write code to perform various documentation tasks. Copy – add a couple of variables, a data set label, and variable labels Create -

Macros & friends Different macros are constructed to report on: “header information” missing values details on non-missing values “header information” (i.e. variable name, label, etc.), missing values (including different kinds of special missing values), and then details on non-missing values, differential by variable type (character, continuous, categorical). Additionally, the program accesses the metadata and outputs text files with macro calls to the macros created above conditional upon the variable type in the metadata and reporting macros, that are then reused in the program as include files

Macros & friends %MACRO header(varname,order); DATA temp&order.a; LENGTH sentence1 . . . $ 500 blurb $ 25000 . . .; SET dd.heart_cb (WHERE=(name="&varname")); namecolon=CATS('^{STYLE [FONTSIZE=10pt FONTWEIGHT=bold]',name,":}"); labelfmt=CATS('^{STYLE [FONTSIZE=10pt FONTWEIGHT=bold]',label,"}"); sentence1=CATX(' ',namecolon,labelfmt); . . . blurb=CATT(sentence1,sentence2,sentence3); LABEL blurb =" "; RUN; . . . %MEND; This is one of a number of macros – but we don’t really want to call differential macros by hand – it would take hours, so…

Macros & friends The rest of the program: accesses the metadata outputs text files with macro calls to the macros created above conditional upon the variable type in the metadata outputs reporting macros to be reused in the program as include files. This is where the review of the metadata spreadsheet comes in handy

Macros & friends header missing missing detail detail This is where the review of the metadata spreadsheet comes in handy detail

Macros & friends This is where the review of the metadata spreadsheet comes in handy

Macros & friends This codebook printout does use a special style template, noborders. The code for this is available on the support.SAS.com website and provided in the zip file of code available from me.

Don’t stop with a codebook! Similarly, metadata can be accessed to create label, format, and length, etc. statements. The resulting statements can be included in other programs seamlessly. This is where the review of the metadata spreadsheet comes in handy

Conclusion SAS provides numerous opportunities for creating self-documenting data sets. With care at the onset of a project, programmers can ensure quality data and accurate documentation. SAS enables the creation of user-friendly documentation, and self-generation of components of SAS programs. Only code snippets are shown here: full code is available from the author upon request.

Contact me! Name: Louise Hadden Organization: Abt Associates Inc. Address: 55 Wheeler St. City, State ZIP: Cambridge, MA 02138 Work Phone: 617-349-2385 E-mail: louise_hadden@abtassoc.com LinkedIn: Louise Hadden Twitter: ceeott56 SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies.