




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、SAS® ProgramI:EssentialsCourse NotesSAS® ProgramI: Essentials Course Notes was developed by Michelle Buchecker, Sarah Calhoun,and Larry Stewart. Additional contributions wereby Warren Repole. Editing and productionsupport was provided by the Curriculum Development and Support Department.SA
2、S 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.SAS® ProgramI: Essentials Course
3、 NotesCopyright ã 2004 by SAS Institute Inc., Cary, NC 27513, USA. Printed in theUnited States of America. No part of this publication may be reproduced, stored in a retrieval system,or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the pri
4、or written permission of the publisher, SAS Institute Inc.Book code 59728, course code PROG1, prepared date 29Apr04.iiiFor Your InformationTable of ContentsCourse DescriptionviTo learn moreviiPrerequisitesviiiGeneral ConventionsixChapter 1Introduction1-11.1An Overview of the SAS System1-3Chapter 2Ge
5、tting Started with the SAS® System2-12.1Introduction to SAS Programs2-32.2Running SAS Programs2-82.3Mastering Fundamental Concepts2-312.4Diagnosing and Correcting Syntax Errors2-412.5Exploring Your SAS Environment (Self-Study)2-522.6Solutions to Exercises2-67Chapter 3Getting Familiar with SAS
6、174; Data Sets3-13.1SAS Data Libraries3-33.2Solutions to Exercises3-16Chapter 4Producing List Reports4-14.1Getting Started with the PRINT Procedure4-34.2Sequencing and GrouObservations4-144.3Identifying Observations (Self-Study)4-224.4Special WHERE Statement Operators (Self-Study)4-28ivFor Your Info
7、rmation4.5Solutions to Exercises4-31Chapter 5Enhng Output5-15.1Customizing Report Appearance5-35.2Formatting Data Values5-85.3Creating HTML Reports5-235.4Solutions to Exercises5-29Chapter 6Creating SAS® Data Sets6-16.1ing Raw Data Files: Column Input6-36.2ing Raw Data Files: Formatted Input6-20
8、6.3Examining Data Errors6-306.4Assigning Variable Attributes6-406.5Changing Variable Attributes (Self-Study)6-476.6ing Excel Spsheets (Self-Study)6-626.7Solutions to Exercises6-77Chapter 7DATA Step Program. 7-17.1ing SAS Data Sets and Creating Variables7-37.2Conditional Processing7-167.3Dropand KeeV
9、ariables (Self-Study)7-327.4ing Excel Spsheets Containing Date Fields (Self-Study)7-357.5Solutions to Exercises7-40Chapter 8Combining SAS® Data Sets8-18.1Concatenating SAS Data Sets8-38.2Merging SAS Data Sets8-14vFor Your Information8.3Combining SAS Data Sets: Additional Features (Self-Study)8-
10、348.4Solutions to Exercises8-37Chapter 9Producing Summary Reports9-19.1Introduction to Summary Reports9-39.2Basic Summary Reports9-69.3The REPORT Procedure9-259.4The TABULATE Procedure (Self-Study)9-409.5Solutions to Exercises9-55Chapter 10Introduction to Graphics (Optional)10-110.1Producing Bar and
11、 Pie Charts10-310.2Enhng Output10-1610.3Producing Plots10-2410.4Solutions to Exercises10-35Chapter 11Additional Resources.11-111.1 Resources11-3Appendix AIndexA-1viFor Your InformationCourse DescriptionThis three-day course focuses on how to······raw data files and SAS
12、data setsinvestigate and summarize data by generating frequency tables and descriptive statistics create SAS variables and recode data valuessubset datacombine multiple SAS filescreate listing, summary, HTML, and graph reports.After completing this course, you should be able to···
13、3;···a SAS data seta raw data filecombine SAS data sets through concatenation and mergingcreate a SAS variable through the assignment statement and conditional logicinvestigate and summarize your datacalculate simple statisticscreate list, summary, HTML, and graph reports.For Your Inf
14、ormationviiTo learn moreA full curriculum of general and statistical instructor-based training is available at any of the Institutes training facilities. Institute instructors can also provide on-site training.For information on other courses in the curriculum, contact the SAS EducationDivision at 1
15、-, or sendto training. You can alsofind this information on the Web at as well as in theTraining Course Catalog.For a list of other SAS books that relate to the topics covered in thisCourse Notes, USA customers can contact our SAS Publishing Department at1-or sendto sasbook. Customers outside theUSA
16、, please contact your local SAS office.Also, see the Publications Catalog on the Web at for a complete list of books and a convenient order form.viiiFor Your InformationPrerequisitesBefore attending this course, you should have completed the Introduction to ProgramConceptsUsing SAS® Software co
17、urse or have at least six months of programSpecifically, you should be able toexperience.···understand file structures and systemds on your operating systemswrite systemunderstand programds to create and access system fileslogic.ixFor Your InformationGeneral ConventionsThis section ex
18、plains the various conventions used in presenting text, SAS language syntax, and examples in this book.Typographical ConventionsYou will see several type styles in this book. This list explains the meaning of each style:UPPERCASE ROMANis used for SAS statements and other SAS language elements when t
19、hey appear in the text.identifies terms or concepts that are defined in text. Italic is also used for book titles when they are referenced in text, as well as for various syntax and mathematical elements.is used for emphasis within text.italicboldmonospaceis used for examples of SAS programstatement
20、s and for SAS characterstrings. Monospace is also used to refer to variable and data set names, fieldnames in windows, information in fields, and user-d information.selectindicates selectable items in windows and to represent selectable items.s. This book also uses iconsSyntax ConventionsTeral forms
21、 of SAS statements andds shown in this book include only that part of thesyntax actually taught in the course. For complete syntax, see the appropriate SAS reference guide.This is an example of how SAS syntax is shown in text:···PROC and CHART are in uppercase bold because they are SA
22、S keywords. DATA= is in uppercase to indicate that it must be spelled as shown.SAS-data-set is in italic because it represents a value that you supply. In this case, the value must be the name of a SAS data set.HBAR and VBAR are in uppercase bold because they are SAS keywords. They are separated by
23、a vertical bar to indicate they are mutually exclusive; you can choose one or the other.chart-variables is in italic because it represents a value or values that you supply.</ options> represents optional syntax specific to the HBAR and VBAR statements. The angle···bracke the sl
24、ash.the slash as well as options because if no options are specified you do not include·RUN is in uppercase bold because it is a SAS keyword.PROC CHART DATA = SAS-data-set;HBAR | VBAR chart-variables </ options>RUN;xFor Your InformationChapter 1Introduction1.1An Overview of the SAS System
25、1-31-2Chapter 1 Introduction1.1 An Overview of the SAS System1-31.1An Overview of the SAS SystemComponents of the SAS System4BBuussinineessss SSooluluttioionnssWWeebb EEnnaabblelemmeennttVViissuuaalliizzaattioionn aannddDDisisccoovveerryyAApppplliiccaattiioonnDDeevveellooppmmeennttAAnnaallyyttiiccaa
26、llBBaasseeSSAASSUUsseerr IInntteerrffaacceessDDaattaaAAcccceessss aanndd MMaannaaggeemmeennttRReeppoorrttiinngg aanndd GGrraapphhiiccssObjectivesn Understand the structure and design of the SAS System.n Introduce the course scenario.31-4Chapter 1Introductiondata accessdata management data analysisad
27、dresses the data required by the application. shapes data into a form required by the application.summarizes, reduces, or otherwise transforms raw data into meaningful and useful municates information in ways that clearly demonstrate its significance.data presentationTurning Data into
28、 InformationProcess of delivering meaningful information:n 80% data-related access scrub transform manage store and retrieven 20% analysis.6Data-Driven TasksThe functionality of the SAS System is built around the four data-driven tasks common to virtually any application:1. data access2. data manage
29、ment3. data analysis4. data presentation.51.1 An Overview of the SAS System1-5Design of the SAS SystemMultiVendor Architecture90%10%independentdependentPCWorkstationServers/MainframeSuperMidrangeComputer8Turning Data into InformationDataInformation7PROCStepsSASData SetsDATAStep1-6Chapter 1Introducti
30、on In order to access databases such as ORACLE, the SAS/ACCESS product for your given Database Management System (DBMS) must be licensed, in addition to Base SAS software.Course ScenarioIn this course, you will be working with business data from International Airlines (IA). The various kinds of data
31、 IA maintains aren flight datan passenger datan cargo datan employee datan revenue data.10Design of the SAS SystemMultiEngine ArchitectureDB2RdbINGRESdBaseDDAATTAASYBASEORACLEINFORMIX91.1 An Overview of the SAS System1-7Course ScenarioSome tasks you will be perforaren importing datan creating a list
32、 of employeesn producing a frequency table of job codesn summarizing datan creating a report of salary information.111-8Chapter 1 IntroductionChapter 2Getting Started with theSAS® System2.1Introduction to SAS Programs2-32.2Running SAS Programs2-82.3Mastering Fundamental Concepts2-312.4Diagnosin
33、g and Correcting Syntax Errors2-412.5Exploring Your SAS Environment (Self-Study)2-522.6Solutions to Exercises2-672-2Chapter 2 Getting Started with the SAS® System2.1 Introduction to SAS Programs2-32.1Introduction to SAS ProgramsSAS ProgramsA SAS program is a sequence of steps that the user subm
34、its for execution.DATA steps are typically used to createRRaawwSAS data sets.DDaattaaDDAATTAA SASPPRROOCCRReeppoorrtt SStteeppDataSStteeppSetSASPROC steps are typically used to processDataSetSAS data sets (that is, generate reports and graphs, edit data, and sort data).4Objectivesn State the compone
35、nts of a SAS program.n State the modes in which you can run a SAS program.32-4Chapter 2Getting Started with the SAS® SystemExamples of raw data file names:The DATA step creates a temporary SAS data set named work.staff by the four variables described in the INPUT statement from the raw data fil
36、e.The PROC PRINT step creates a listing report of the work.staff data set.ingThe PROC MEANS step creates a report with summary statistics for the variableSalary for each value of JobTitle.1 Any reference to z/OS applies to OS/390, unless otherwise noted.z/OS1 (OS/390)g1.rawdata(emplist)Win
37、dowsc:workshopwinsasprog1emplist.datUNIX/users/userid/emplist.datSAS ProgramsDATAStepPROCSteps5data work.staff;infile 'raw-data-file'input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59;run;proc print data=work.staff; run;proc means data=work.staff; class JobTitle;var Salary
38、; run;2.1 Introduction to SAS Programs2-5 A SAS program executed in batch or noninteractive mode can contain RUN statements, but does not require any RUN statements to execute successfully because the entire program is executed by default. The presence of the RUN statement depends on the programmer&
39、#39;s preference.Step Boundaries7data work.staff;infile 'raw-data-file'input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59;run;proc print data=work.staff; proc means data=work.staff;class JobTitle;var Salary; run;Step BoundariesSAS steps begin with an DATA statementn PROC s
40、tatement.SAS detects the end of a step when it encountersn a RUN statement (for most steps)n a QUIT statement (for some procedures)n the beginning of another step (DATA statement or PROC statement).62-6Chapter 2 Getting Started with the SAS® SystemExamples of raw data file names:SAS Windowing E
41、nvironmentInteractive windows enable you to interface with SAS.9Running a SAS ProgramYou can invoke SAS inn interactive windowing mode (SAS windowing environment)n interactive-driven mode (SAS Enterprise Guide, SAS/ASSIST, SAS/AF, or SAS/EIS software)n batch moden noninteractive mode.8z/OS (OS/390)u
42、g1.rawdata(emplist)Windowsc:workshopwinsasprog1emplist.datUNIX/users/userid/emplist.dat2.1Introduction to SAS Programs2-7 Thed for invoking SAS at your site may be different from thedefault shown above. Ask your SAS administrator for the invoke SAS at your site.d toNoninteractive Execution
43、(Optional)To execute a SAS program in noninteractive mode,n use an editor to store the program in a file. (Directory- based users should use a filetype or extension of SAS.)n identify the file when you invoke SAS. Directory-based:z/OS (OS/390, TSO):11SSAASSIINNPPUUTT(ffilielennaammee)SSAASSffilielen
44、naammeez/OS (OS/390, MVS) Batch ExecutionPlace the JCL appropriate for your location before your SAS statements.10/jobname JOBing info,name / EXEC SAS/SYSIN DD * data work.staff;infile 'raw-data-file'input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59;run;proc print data=wo
45、rk.staff; run;proc means data=work.staff; class JobTitle;var Salary; run;2-8Chapter 2 Getting Started with the SAS® System2.2Running SAS ProgramsSubmitting a SAS ProgramWhen you execute a SAS program, the output generated by SAS is divided into two major parts:SAS log contains information about
46、 the processing of the SAS program, including any warning and error messages.SAS output contains reports generated by SAS procedures and DATA steps.14Objectivesn Invoke the SAS System and include a SAS program into your session.n Submit a program and browse the results.n Navigate the SAS windowing e
47、nvironment.132.2 Running SAS Programs2-9Examples of raw data file names:PROC PRINT Output16The SAS SystemFirstObsLastNameNameJobTitleSalary1 TORRESJANPilot500002 LANGKAMMSARAHMechanic800003 SMITHMICHAELMechanic400004 LEISTNERCOLINMechanic360005 WADEKIRSTENPilot850006 TOMASHARALDPilot1050007 WAUGHTIM
48、Pilot700008 LEHMANNDAGMARMechanic640009 TRETTHAHNMICHAELPilot10000010 TIETZOTTOPilot4500011 O'DONOGHUEARTMechanic5200012 WALKERTHOMASPilot9500013 NOROVIITAJOACHIMMechanic7800014 OESTERBERGANJAMechanic8000015 LAUFFERCRAIGMechanic4000016 TORRJUGDISHPilot4500017 WAGSCHALNADJAPilot7750018 TOERMOENJO
49、CHENPilot65000z/OS (OS/390)g1.rawdata(emplist)Windowsc:workshopwinsasprog1emplist.datUNIX/users/userid/emplist.datSAS Log151 data work.staff;2 infile 'raw-data-file'3 input LastName $ 1-20 FirstName $ 21-304 JobTitle $ 36-43 Salary 54-59;5 run;NOTE: The infile 'raw-data-file
50、9; is: File Name= 'raw-data-file', RECFM=V,LRECL=256NOTE: 18 records werefrom the infile 'raw-data-file'.The minimum record length was 59. Theum record length was 59.NOTE: The data set WORK.STAFF has 18 observations and 4 variables.6 proc print data=work.staff;7 run;NOTE: There were
51、18 observationsfrom the dataset WORK.STAFF.8 proc means data=work.staff;9 class JobTitle;10 var Salary;11 run;NOTE: There were 18 observationsfrom the dataset WORK.STAFF.2-10Chapter 2 Getting Started with the SAS® SystemPROC MEANS Output17The SAS System The MEANS ProcedureAnalysis Variable : Sa
52、laryNJobTitle Obs NMean Std Dev Minimum Mechanic 8 8 58750.00 19151.65 36000.00Pilot 10 10 73750.00 22523.14 45000.00 Analysis Variable : SalaryNJobTitle Obsum Mechanic 8 80000.00Pilot10105000.002.2 Running SAS Programs2-11Running a SAS Program Windows···Start a SAS session.Include an
53、d submit a program. Browse the results.Starting a SAS Session1. Double-click the SAS icon to start your SAS session. How you invoke SAS varies by your operating environment and any customizations in effect at your site.File: c02s2d1.sas2-12Chapter 2Getting Started with the SAS® SystemAll operating environments support the Program Editor. The Microsoft Windows operating environment supports an additional editor, the Enhanced Editor.Because the Program Editor is available on all operating environments, it will be used throughout class. Micro
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医疗机构护士自查与整改措施
- 语言艺术教育教研组工作计划
- 非常规油气开发中的压裂安全与环保措施
- 化妆品生产半成品防护措施
- 环保项目质量保证与创新方案
- 语文写作兴趣培养计划(小学三年级)
- 2025-2030中国海运拼箱行业市场发展前瞻及投资战略研究报告
- 2025-2030中国油炸堆场行业市场现状供需分析及投资评估规划分析研究报告
- 城市基础设施建设的主要施工机械设备计划
- 2025年小学语文毕业升学考试全真模拟卷(文学名著阅读)之《三国演义》经典章节解析试题
- 啤酒采购合同协议书模板
- 大车司机劳务协议书
- 中医把脉入门培训课件
- 学生军训教官合同协议
- 期刊编辑的学术期刊内容审核标准考核试卷
- 高血糖症的急救与护理
- 成人失禁性皮炎的预防与护理
- 知识产权监管培训课件
- 油田节能降耗技术-全面剖析
- 广西钦州市钦州港经济技术开发区中学2025年初三第二学期第一次区模拟化学试题含解析
- 技术信息收集与分析方法考核试卷
评论
0/150
提交评论