Fundamentals Of Programming In SAS: A Case Studies Approach

1y ago
10 Views
2 Downloads
5.64 MB
46 Pages
Last View : 13d ago
Last Download : 3m ago
Upload by : Albert Barnett
Transcription

The correct bibliographic citation for this manual is as follows: Blum, James and Jonathan Duggins. 2019. Fundamentals ofProgramming in SAS : A Case Studies Approach. Cary, NC: SAS Institute Inc.Fundamentals of Programming in SAS : A Case Studies ApproachCopyright 2019, SAS Institute Inc., Cary, NC, USA978-1-64295-228-5 (Hardcover)978-1-63526-672-6 (Paperback)978-1-63526-671-9 (Web PDF)978-1-63526-669-6 (epub)978-1-63526-670-2 (kindle)All Rights Reserved. Produced in the United States of America.For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or byany means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS InstituteInc.For a web download or e-book: Your use of this publication shall be governed by the terms established by the vendor at the time youacquire this publication.The scanning, uploading, and distribution of this book via the Internet or any other means without the permission of the publisher isillegal and punishable by law. Please purchase only authorized electronic editions and do not participate in or encourage electronicpiracy of copyrighted materials. Your support of others’ rights is appreciated.U.S. Government License Rights; Restricted Rights: The Software and its documentation is commercial computer softwaredeveloped at private expense and is provided with RESTRICTED RIGHTS to the United States Government. Use, duplication, ordisclosure of the Software by the United States Government is subjectto the license terms of this Agreement pursuant to, as applicable, FAR 12.212, DFAR 227.7202-1(a), DFAR 227.7202-3(a), andDFAR 227.7202-4, and, to the extent required under U.S. federal law, the minimum restricted rights as set out in FAR 52.227-19(DEC 2007). If FAR 52.227-19 is applicable, this provision serves as notice under clause (c) thereof and no other notice is required tobe affixed to the Software or documentation. The Government’s rights in Software and documentation shall be only those set forth inthis Agreement.SAS Institute Inc., SAS Campus Drive, Cary, NC 27513-2414July 2019SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in theUSA and other countries. indicates USA registration.Other brand and product names are trademarks of their respective companies.SAS software may be provided with certain third-party software, including but not limited to open-source software, which is licensedunder its applicable third-party software license agreement. For license information about third-party software distributed with SASsoftware, refer to http://support.sas.com/thirdpartylicenses.

ContentsForeword . viiAbout This Book . ixAbout These Authors . xiAcknowledgments . xiiiChapter 1: Introduction to SAS . 11.1 Introduction. 11.2 Learning Objectives . 11.3 SAS Environments . 21.4 SAS Fundamentals. 71.5 Output Delivery System . 181.6 SAS Language Basics . 251.7 Chapter Notes . 261.8 Exercises . 30Chapter 2: Foundations for Analyzing Data and Reading Data from Other Sources . 332.1 Learning Objectives . 332.2 Case Study Activity. 342.3 Getting Started with Data Exploration in SAS. 372.4 Using the MEANS Procedure for Quantitative Summaries . 432.5 User-Defined Formats . 482.6 Subsetting with the WHERE Statement. 532.7 Using the FREQ Procedure for Categorical Summaries. 562.8 Reading Raw Data . 622.9 Details of the DATA Step Process . 702.10 Validation. 782.11 Wrap-Up Activity . 822.12 Chapter Notes . 822.13 Exercises . 85Chapter 3: Bar Chart Basics, Data Diagnostics and Cleaning, and More on Reading Datafrom Other Sources . 933.1 Learning Objectives . 933.2 Case Study Activity. 943.3 Bar Charts . 963.4 Options and Statements to Style Bar Charts . 1023.5 Creating and Using Output Data Sets from MEANS and FREQ . 1063.6 Reading Raw Data with Informats . 1113.7 Handling Incomplete Records . 1183.8 Reading and Writing Raw Data with the IMPORT and EXPORT Procedures . 1233.9 Simple Data Inspection and Cleaning . 1273.10 Wrap-Up Activity . 1353.11 Chapter Notes . 1363.12 Exercises . 137

iv ContentsChapter 4: Combining Data Vertically in the DATA Step . 1474.1 Learning Objectives.1474.2 Case Study Activity .1484.3 Vertically Combining SAS Data Sets in the DATA Step .1504.4 Managing Data Sets During Combination .1564.5 Creating Variables Conditionally .1704.6 Working with Dates and Times .1774.7 Data Exploration with the UNIVARIATE Procedure.1804.8 Data Distribution Plots .1854.9 Wrap-Up Activity.1934.10 Chapter Notes .1944.11 Exercises .194Chapter 5: Joining Data Sets on Common Values and Measuring Association . 2015.1 Learning Objectives.2015.2 Case Study Activity .2015.3 Horizontally Combining SAS Data Sets in the DATA Step .2045.4 Match-Merge Details .2145.5 Controlling Output .2205.6 Procedures for Investigating Association .2235.7 Restructuring Data with the TRANSPOSE Procedure.2335.8 Wrap-Up Activity.2405.9 Chapter Notes .2415.10 Exercises .242Chapter 6: Restructuring Data and Introduction to Advanced Reporting . 2556.1 Learning Objectives.2556.2 Case Study Activity .2556.3 DO Loops .2586.4 Arrays .2646.5 Interchanging Row and Column Information with Arrays.2696.6 Generating Tables with PROC REPORT .2746.7 Wrap-Up Activity.2876.8 Chapter Notes .2876.9 Exercises .290Chapter 7: Advanced DATA Step Concepts . 2997.1 Learning Objectives.2997.2 Case-Study Activity .2997.3 Reading Complex Raw Data Structures .3017.4 Working Across Records in the DATA Step .3117.5 Customizations in the REPORT Procedure .3207.6 Connecting to Spreadsheets and Relational Databases .3417.7 Wrap-Up Activity.3447.8 Chapter Notes .3457.9 Exercises .347

Contents vChapter 8: Clinical Trial Case Study . 3578.1 Scenario, Learning Objectives, and Introductory Activities . 3578.2 Reading and Summarizing Visit and Lab Data . 3628.3 Improving Reading of Data; Creating Charts . 3648.4 Working with Data Stacked Across Visits (and Sites) . 3668.5 Assembling and Summarizing Data—Sites 1, 2, and 3 . 3698.6 Data Restructuring and Report Writing . 3758.7 Advanced Data Reading and Report Writing—Connecting to Spreadsheets and Databases . 3768.8 Comprehensive Activity . 379Index . 381

vi Contents

ForewordTo ReadersThis book is designed to help you develop an understanding of the SAS programming language and to helpyou develop good programming practices. It is intended as a learning guide and a skill builder, not as areference book. To that end, it introduces sets of topics within each chapter that are connected through asingle case study. Concepts are introduced on an as-needed basis to complete required tasks, so you areimmediately exposed to writing complete programs. As further concepts are introduced they might be newtopics, or they might revisit previously introduced topics at a more complex level. This reflects how many ofthe best SAS programmers have built their talents—by continually adding layers of knowledge onto a base setof skills. The book mimics this type of experience by increasing the complexity of the case study, requiring theaddition of newer skills, or more complex versions of earlier skills, as they are needed.Because of this circling back to content from previous chapters, a pedagogical concept known as a spiralcurriculum, you will not learn everything this book covers on a topic in any single chapter. Of course, no onebook could serve the purpose of giving a complete treatment of all concepts included; therefore, you willoften be referred to outside resources, such as SAS Documentation, for a full description of syntax or for moredetailed commentary. SAS Documentation is the standardized name used in this text for the collection of helpfiles and examples provided by SAS. This documentation is available via the Help menu in SAS or online.Reading such references is a strategy commonly used by the best SAS programmers to refine their abilitiesand is an important habit for you to develop to build your skills as a SAS programmer and to expand on thoseskills in the future.Due to the introduction of concepts in spiral fashion, it is important to begin with the setup material inChapter 1 and then to proceed through the book sequentially. For easy reference, the numbering on alloutput in Chapters 1 through 7 directly corresponds to the number of the program that generates it.However, not all programs generate output. In all chapters, the programs, output, tables, and figures arenumbered sequentially within each section. The same case study is used to provide continuity through thenarrative when building on earlier concepts. Other case studies are also available for use to build continuityfor additional programming activities and exercises. This includes a case study located in Chapter 8 for whichthe sections are aligned with the learning objectives of each chapter. Additional case studies are availableonline by visiting the author page for either author.To Classroom InstructorsAs stated in the previous section, this book is designed to tap into some of the best practices in educationaltheory as it spirals back onto topics throughout your course. It is designed by instructors with over 25 years ofcombined experience in teaching SAS either in the classroom or in industry. The more technical details areisolated in their own sections so that you can easily include or exclude them to fit the needs of your course.Multiple case studies are also provided so that the case study assignments can be customized for yourstudents’ interests and to the content presented in your course. The case study provided in Chapter 8 ensuresstudents have immediate access to a case study for reference while reading the text. Additional case studiesare made available through the author pages for either author to ensure you get the benefit of updatedmaterials on a regular basis. Any instructional materials will also be available either via the author pages (forpublic resources) or by contacting SAS to verify your status as an instructor (for instructor-only materials).These resources will be regularly updated.

viii Fundamentals of Programming in SAS: A Case Studies ApproachAbout the IPUMS CPS DataThe IPUMS CPS data includes the Integrated Public Use Microdata Series (IPUMS) and Current PopulationSurvey (CPS) beginning in 1962. These data sets provide person- and household-level information about avariety of demographic variables. A cross-section of recent data (2001, 2005, 2010, and 2015) was releasedfor this publication and is included here as the main case study in the narrative. Visit https://cps.ipums.org tolearn more about the IPUMS CPS or to extract newer data to continue honing your SAS programming skills.

About This BookWhat Does This Book Cover?This text covers a wide set of topics available in the Base SAS software including: DATA step programming including:o Reading data sets from non-SAS sourceso Combining and restructuring SAS data setso Functions and conditional logico DO loops and arrays Basic analysis procedures: MEANS, FREQ, CORR, and UNIVARIATE Reporting procedures: CONTENTS, PRINT, and REPORT Restructuring data with PROC TRANSPOSE Visualization with the SGPLOT and SGPANEL procedures SAS formats and the FORMAT procedure Output Delivery SystemWhile this book covers the foundations of the topics listed above, additional details are often beyond thescope of this text. References are provided for those interested in further study.Is This Book for You?Are you trying to learn SAS for the first time? Are you hoping to eventually earn your Base SAS certificationand become a SAS Certified Professional? Are you already comfortable with some SAS programming but arelooking to hone your skills? If the answer to any of those questions is “yes,” then this is the book for you! Thisbook takes a novel approach to learning SAS programming by helping you develop an understanding of thelanguage and establish good programming practices. By following a single case study throughout the text andcircling back to previous concepts, this book aids in the learning of new topics through explicit connections toprevious material. Just as the best SAS programmers expand their capabilities by continually adding to theiralready impressive skill sets, as you read this text you will gain the skills and confidence to take on largerchallenges with the power of SAS.This book does not assume any prior knowledge of the SAS programming language. However, anunderstanding of how file paths function in your operating system is necessary to facilitate the storage andretrieval of data sets, raw data files, and other files such as documents and graphics.What Should You Know About the Examples?This book includes tutorials for you to follow to gain hands-on experience with SAS. The majority of theexamples are based on a case study using real data. Some examples use subsets of the case study data orintroduce smaller data sets to help illustrate a topic. Chapters 2 through 7 contain a wrap-up activity that usesthe case study to tie together concepts from the current chapter, and every chapter references another casestudy contained in Chapter 8 for further practice. You need access to the software listed in the next section tocomplete the exercises.

x Fundamentals of Programming in SAS: A Case Studies ApproachFor easy reference, the numbering on all output in Chapters 1 through 7 directly corresponds to the numberof the program that generated it. However, not all programs generate output. In all chapters, the programs,output, tables, and figures are numbered sequentially within each section.Software Used to Develop the Book's ContentSAS 9.4TS1M3 and higher were used to develop the examples and exercises. To follow along with theexamples simultaneously or to complete the exercises, you only need the Base SAS software except for theportions of Chapters 7 and 8 that use SAS/ACCESS to connect to Microsoft Excel workbooks and MicrosoftAccess databases.Example Code and DataYou can access the example code and data for this book by linking to its author page athttps://support.sas.com/authors.SAS University EditionThis book is compatible with SAS University Edition. If you are using SAS University Edition, then beginhere: https://support.sas.com/ue-data.Where Are the Exercise Solutions?Readers: Exercise solutions to selected exercises are posted on the author page athttps://support.sas.com/authors.Classroom Instructors: To obtain the full solutions, contact saspress@sas.com.We Want to Hear from YouDo you have questions about a SAS Press book that you are reading? Contact us at saspress@sas.com.SAS Press books are written by SAS Users for SAS Users. Please visit sas.com/books to sign up to requestinformation on how to become a SAS Press author.We welcome your participation in the development of new books and your feedback on SAS Press books thatyou are using. Please visit sas.com/books to sign up to review a bookLearn about new books and exclusive discounts. Sign up for our new books mailing list today .html.Learn more about these authors by visiting their author pages, where you can download free book excerpts,access example code and data, read the latest reviews, get updates, and .com/duggins

About These AuthorsJames Blum is a Professor of Statistics at the University of North Carolina Wilmington wherehe has developed and taught original courses in SAS programming for the university for nearly20 years. These courses cover topics in Base SAS, SAS/SQL, SAS/STAT, and SAS macros. He alsoregularly teaches courses in regression, experimental design, categorical data analysis, andmathematical statistics; and he is a primary instructor in the Master of Data Science programat UNC Wilmington, which debuted in the fall of 2017. He has experience as a consultant ondata analysis projects in clinical trials, finance, public policy and government, and marinescience and ecology. He earned his MS in Applied Mathematics and PhD in Statistics fromOklahoma State University.Jonathan Duggins is an award-winning Teaching Professor at North Carolina State University,where his teaching includes multiple undergraduate and graduate programming courses. Hisexperience as a practicing biostatistician influences his classroom instruction, where heincorporates case studies, utilizes large data sets, and holds students accountable for the bestpractices used in industry. Jonathan is a member of the American Statistical Association and isactive with the North Carolina chapter. He has been a SAS user since 1999 and has presentedat both regional and national statistical and SAS user group conferences. Jonathan holds a BSand MS in mathematics from the University of North Carolina Wilmington and an MS and PhDin statistics from Virginia Tech.Learn more about these authors by visiting their author pages, where you can download free book excerpts, accessexample code and data, read the latest reviews, get updates, and s.com/duggins

xii

Chapter 1: Introduction to SAS1.1 Introduction. 11.2 Learning Objectives . 11.3 SAS Environments . 21.3.1 The SAS Windowing Environment . 21.3.2 SAS Studio and SAS University Edition . 51.4 SAS Fundamentals . 71.4.1 SAS Language Basics. 71.4.2 SAS DATA and PROC Steps . 81.4.3 SAS Libraries and Data Sets. 111.4.4 The SAS Log . 161.5 Output Delivery System . 181.6 SAS Language Basics . 251.6.1 SAS Language Structure . 251.6.2 SAS Naming Conventions .

Multiple case studies are also provided so that the case study assignments can be customized for your students' interests and to the content presented in your course. The case study provided in Chapter 8 ensures students have immediate access to a case study for reference while reading the text. Additional case studies

Related Documents:

POStERallows manual ordering and automated re-ordering on re-execution pgm1.sas pgm2.sas pgm3.sas pgm4.sas pgm5.sas pgm6.sas pgm7.sas pgm8.sas pgm9.sas pgm10.sas pgm1.sas pgm2.sas pgm3.sas pgm4.sas pgm5.sas pgm6.sas pgm7.sas pgm8.sas pgm9.sas pgm10.sas 65 min 45 min 144% 100%

SAS OLAP Cubes SAS Add-In for Microsoft Office SAS Data Integration Studio SAS Enterprise Guide SAS Enterprise Miner SAS Forecast Studio SAS Information Map Studio SAS Management Console SAS Model Manager SAS OLAP Cube Studio SAS Workflow Studio JMP Other SAS analytics and solutions Third-party Data

Both SAS SUPER 100 and SAS SUPER 180 are identified by the “SAS SUPER” logo on the right side of the instrument. The SAS SUPER 180 air sampler is recognizable by the SAS SUPER 180 logo that appears on the display when the operator turns on the unit. Rev. 9 Pg. 7File Size: 1MBPage Count: 40Explore furtherOperating Instructions for the SAS Super 180www.usmslab.comOPERATING INSTRUCTIONS AND MAINTENANCE MANUALassetcloud.roccommerce.netAir samplers, SAS Super DUO 360 VWRuk.vwr.comMAS-100 NT Manual PDF Calibration Microsoft Windowswww.scribd.com“SAS SUPER 100/180”, “DUO SAS SUPER 360”, “SAS .archive-resources.coleparmer Recommended to you b

Both SAS SUPER 100 and SAS SUPER 180 are identified by the “SAS SUPER 100” logo on the right side of the instrument. International pbi S.p.AIn « Sas Super 100/180, Duo Sas 360, Sas Isolator » September 2006 Rev. 5 8 The SAS SUPER 180 air sampler is recognisable by the SAS SUPER 180 logo that appears on the display when the .File Size: 1019KB

Jan 17, 2018 · SAS is an extremely large and complex software program with many different components. We primarily use Base SAS, SAS/STAT, SAS/ACCESS, and maybe bits and pieces of other components such as SAS/IML. SAS University Edition and SAS OnDemand both use SAS Studio. SAS Studio is an interface to the SAS

SAS Stored Process. A SAS Stored Process is merely a SAS program that is registered in the SAS Metadata. SAS Stored Processes can be run from many other SAS BI applications such as the SAS Add-in for Microsoft Office, SAS Information Delivery Portal, SAS Web

Jan 01, 2020 · SAS Programming SAS (Statistical Analysis System). SAS is a business application software which is used for DBMS and reporting, visualization and data mining purpose. To begin with sas we must start with sas data manipulation using sas programming Session-1 SAS Jargons and navigation though SAS PC ad SAS EG windows

LSI (SATA) Embedded SATA RAID LSI Embedded MegaRaid Intel VROC LSI (SAS) MegaRAID SAS 8880EM2 MegaRAID SAS 9280-8E MegaRAID SAS 9285CV-8e MegaRAID SAS 9286CV-8e LSI 9200-8e SAS IME on 53C1064E D2507 LSI RAID 0/1 SAS 4P LSI RAID 0/1 SAS 8P RAID Ctrl SAS 6G 0/1 (D2607) D2516 RAID 5/6 SAS based on