版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、SAS Basic Knowledge,References,The Little SAS Book, Lora D. Delwiche and Susan J. Slaughter SAS Programming in the Pharmaceutical Industry, Jack Shostak SAS V8基础教程,汪嘉冈编,中国统计出版社,2004 Common Statistical Methods for Clinical Research with SAS Examples(2ed), Walker Glenn, 2002 SAS Product Online Documen
2、ts Statistical Analysis SAS/STAT 9.1 Users Guide SAS/ETS 9.1 Users Guide SAS Google Group SAS Forum and Resources from Internet,Objective,Get entry to SAS, understand the functionalities of windows, and learn to use online help and system options Understand the concepts of SAS files and SAS library;
3、 browse the properties and contents of SAS library; assign SAS library Understand the definition of SAS dataset (observations, variables and their properties), the input and output format, the properties of datasets. Try to browse, edit and create datasets in Viewtable Know Data Step and Proc Step K
4、now the basic rules of SAS programming writing,Contents,SAS Working Environment,SAS Basic Knowledge,Base of SAS Programming,General Introduction to SAS. SAS Graphical User Interface SAS Help,SAS Library, SAS Dataset SAS Menu Basic Operation,Definition for Data Step, Proc Step Rules of SAS Programmin
5、g Writing,Introduction to SAS,Started out as a software package for statistical analysis Branched out into graphics, online data entry and compilers for C programming language Grew to include tools for visualizing data, administrating data warehouse, and building interfaces to the World wide Web Con
6、tinued to grow with products for cleansing messy data, and analyzing genetic data,Statistical Analysis System,Components of the SAS System,Reporting and Graphics,Data Access and Management,User Interfaces,Analytical,Visualization and Discovery,Base SAS,Business Solutions,Application Development,Web
7、Enablement,Data-Driven Tasks,The functionality of the SAS System is built around the four data-driven tasks common to virtually any application,Invoke SAS in Interactive windowing mode (SAS windowing environment) Interactive menu-driven mode (SAS Enterprise Guide, SAS/ASSIST, SAS/AF, or SAS/EIS soft
8、ware) Batch mode Non-interactive mode,Entry to SAS,Interactive Working Environment,Menu Command Tools Log Output Explorer Editor Result Status,SAS Windows,Submit and view the results of a SAS program using these windows:,Enhanced Editor contains the SAS program to be submitted. Log contains informat
9、ion about the processing of the SAS program, including any warning and error messages. Output contains reports generated by SAS procedures and DATA steps. In the Explorer window, you can view and manage your SAS files and create shortcuts to non-SAS files. Use this window to create new libraries and
10、 SAS files; open any SAS file; and perform most file management tasks such as moving, copying, and deleting files. Selecting View - Show Tree from the Explorer menu bar allows you to choose to display the Explorer window with or without a tree view of its contents. The Results window helps you navig
11、ate and manage the output from SAS code which you submit. You can view, save, and print individual items of output.,Reading the SAS log,When a program is executed a log is generated in the log window. ALWAYS read log! It contains useful information. There are three types of log messages, colored blu
12、e, green and red. NOTE: blue, general (good) information, useful, number of obs. WARNING: green, not an error but SAS informs you that you may have a problem, although it does not stop processing, still creates a data set ERROR: red, an error in the code, SAS cannot process the data step, it stops!
13、If you are running the data step to replace an older version of a data set, it has NOT been replaced!,Changing Default options in SAS,From the Tools menu on the main menu bar, select Options,Using SAS System Options,Options,Change Font in Program, Log, and Output Enhanced Editor : Tools - Options En
14、hanced Editor Options Appearance Program, Log and Output: Tools - Options Fonts Enhanced Editor System formchar Preferences Enhanced Editor Keys Comment out the current selection (or current line if there is no selection) using line comments. Ctrl + / Remove line comments for the lines in the curren
15、t selection (or the current line if there is no selection). Ctrl + Shift +/,Keys,An easy way to work with SAS is to use the function keys (F1-F12), instead of using the mouse and clicking. You can define the keys any way you like, below are suggestions. To change keys settings: type keys in the comm
16、and line, change the definitions and then choose Save from the file menu. F3 clear log; clear output; wpgmF4 recallF5 wpgmF6 logF7 outputF8 submitF12 clear F1 helpF2 dirF3 log; clear; output; clear; pgm; clear; zoom on;F4 recallF5 pgm; zoom onF6 log; zoom onF7 output; zoom onF8 zoom off;submitF9 key
17、sF11 command bar,Commands,Pgm Log Output Help Clear Keys Submit ,autoexec.sas file,Can be customized for different projects. For example, most projects have a unique libname, format library and macro library. You may have standard libnames, formats and macro libraries as well. Default: The SAS AUTOE
18、XEC.SAS is an external file located in the same physical location as SAS.EXE. It is run when SAS is executed. Example of a simple AUTOEXEC.SAS:,libname sasdata c:project1sasdata; libname rawdata c:project1rawdata; options macautosource sasautos = (c:project1sasmacro c:librarymacros); libname library
19、 c:project1sasdata; proc format library=library; run;,sasInitialFolder,If you try to open a SAS Program File with the Open button or if you try to save your work with the Save button, you will get a dialog box that opens to a very out-of-the-way place. E.g.: C:My Documentssheny04My SAS filesV9.2. Yo
20、u can make SAS use your project folder as the default folder with the sasInitialFolder=“.”; Use autoexec and sasInitialFolder to customize your project SAS shorcut. Refer to document: How to set up SAS Shortcut for a study.doc,SAS Graphical User Interface,Import data Export data,Analysing your data
21、(The SAS Analyst application),The Analyst Application provides easy access to commonly used statistical and graphical analysis capabilities.,Submit a SAS Program,Write a new SAS program in the enhanced editor Submit SAS program Browse the messages in log Examine the program results in output window
22、Save SAS program to a file,SAS Online Help,Web link ,Online Help,SAS Online Documentation,Click the plus sign sub-content will show up,Expand SAS Procedure Guidethen expand Procedures,Reference for Proc Print,Using Dictionary,Finding SAS function in dictionary,SAS STAT Procedure,Search,Contents,SAS
23、Working Environment,SAS Basic Knowledge,Base of SAS Programming,General Introduction to SAS. SAS Graphical User Interface SAS Help,SAS Library, SAS Dataset SAS Menu Basic Operation,Definition for Data Step, Proc Step Rules of SAS Programming Writing,SAS Library,When you invoke SAS, you automatically
24、 have access to Temporary SAS data library - Work Permanent SAS data libraries - SASHELP, SASUSER,A SAS data library is a collection of SAS files that are recognized as a unit by SAS. A SAS data set is one type of SAS file stored in a data library.,SAS Library and Physical Location,Several libraries
25、 could point to the same physical location; one library could connect to several physical locations Library includes all the SAS files in its connected physical locations, but not the files in the sub-directory. When your session ends, the association between the libref and the physical location of
26、your files is broken. SAS can only make an association between a libref and an existing file folder.,Create a Library,Click Submit command libassign Right click in explorer,Assigning a Libref,Rules for naming a libref: The name must be 8 characters or less. The name must begin with a letter or under
27、score. The remaining characters must be letters, numbers, or underscores.,proc datasets lib=libref (details); proc contents data=libref._all_ nods; proc contents data=libref.sas-data-set-name; Libname libref clear; Libname libref; Libname libref list; Libname _all_ list;,Two-Level SAS Filenames,The
28、first level of name (libref) refers to the library. The second level of name (filename) refers to the file in the library.,Every SAS file has a two-level name:,SAS DATASET,A SAS data set is a specially structured file that contains data values. Data must be in the form of a SAS data set to be proces
29、sed by many SAS procedures and some DATA step statements.,Descriptor and Data Portion,SAS data sets have a descriptor portion and a data portion.,Descriptor Portion,Data Portion,Browsing the Descriptor Portion,The descriptor portion of a SAS data set contains general information about the SAS data s
30、et such as data set name and number of observations variable attributes, such as name, type, length, position, informat, format, and label. The CONTENTS procedure displays the descriptor portion of a SAS data set.,PROC CONTENTS DATA=SAS-data-set; RUN;,Browsing the Descriptor Portion,Name Type Length
31、 Label Informat Format,Browsing the Data Portion,The data portion of a SAS data set is a rectangular table of character and/or numeric data values. The variables (columns) in the table correspond to fields of data, and each data column is named. The observations (rows) in the table correspond to rec
32、ords or data lines.,Variable Names Variable Values Numeric Values Character Values,View Table,Browse, edit and create SAS dataset in View Table window:,SAS Data Set and Variable Names,SAS names Can be 32 characters long. Can be uppercase, lowercase, or mixed case. Must start with a letter or undersc
33、ore. Subsequent characters can be letters, underscores, or numeric digits.,Contents,SAS Working Environment,SAS Basic Knowledge,Base of SAS Programming,General Introduction to SAS. SAS Graphical User Interface SAS Help,SAS Library, SAS Dataset SAS Menu Basic Operation,Definition for Data Step, Proc
34、Step Rules of SAS Programming Writing,SAS Programs,A SAS program is a sequence of steps that the user submits for execution. DATA steps are typically used to create SAS data sets. PROC steps are typically used to process SAS data sets (that is, generate reports and graphs, edit data, and sort data).
35、,SAS Programs,data demog; input subjid $ dosedate: MMDDYY10. dosetime: time5. drugname $; cards; 1001 10/30/2009 10:00 A 1006 10/06/2009 10:01 A ; run; proc print data=demog; run; proc contents data=demog; run;,DATA Step,PROC Steps,SAS Programs,SAS steps begin with a DATA statement PROC statement SA
36、S detects the end of a step when it encounters A RUN statement (for most steps) A QUIT statement (for some procedures) The beginning of another step (DATA statement or PROC statement),SAS Programs,data demog; input subjid $ dosedate: MMDDYY10. dosetime: time5. drugname $; cards; 1001 10/30/2009 10:0
37、0 A 1006 10/06/2009 10:01 A ; run; proc print data=demog; run; proc contents data=demog; run;,Data Step,DATA steps typically create or modify SAS data sets. They can also be used to produce custom-designed reports. For example, you can use DATA steps to put your data into a SAS data set compute valu
38、es check for and correct errors in your data produce new SAS data sets by subsetting, merging, and updating existing data sets.,DATA Step - Examples,data test1 test2(keep=subjid wt ht); set test; run; data test1; set test(keep= subjid age wt); if age=24 then _criteria=Group1; else if 25=age28 then _
39、criteria=Group2; else do; if wt70 then _criteria=Group3; else _criteria=Group4; end; run; data test1 test2 test3; set test; select (subjid); when (10011001) output test1; when (10011002) output test2; otherwise output test3; end; run;,PROC (procedure) steps are pre-written routines that enable you t
40、o analyze and process the data in a SAS data set and to present the data in the form of a report. They sometimes create new SAS data sets that contain the results of the procedure. PROC steps can list, sort, and summarize data. For example, you can use PROC steps to create a report that lists the da
41、ta produce descriptive statistics create a summary report produce plots and charts.,PROC Step,PROC Step - Examples,proc tabulate data=sashelp.class; class sex age; table sex, age*f=3.; run; proc print data=sashelp.class; run; Proc contents data=sashelp.class; run; Proc means; var age; run;,Basic Pro
42、gramming of SAS,SAS Constant: Numeric: 1 -5 1.25 1.2E23 missing value . Character: CPW missing value SAS operator * * / + - = (EQ) =(NE) (GT) =(GE) | SAS Expressions Used in DATA Steps Examples: Log(x) A=B/C*100 i= i+1,Recommended SAS Programming Styles,Recommended SAS Programming Styles,the more, t
43、he better Working Practice Maintainability Readability Ease of use and validation,General (1),One statement per line Limit the length of lines: 80 Indention: 2 spaces Lower case Comments Use * to introduce or explain Use %* to comment macros Use /*/ to block-comment Standard program header Termination statement RUN for DATA QUIT for PROC SQL Use block styles/modular approaches Blank lines to separate sections Use functions Date/time format: date9. time5. datetime.,General (2),Preserve environment setting before changing them and restoring after completion Library names:
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 数字化转型下SG公司物资采购成本控制的策略创新与实践
- 数字化赋能:基金和社保费电子缴费平台的创新设计与实践
- 数字化浪潮下证券公司综合管理系统的设计与实践:创新、挑战与突破
- 2025 记叙文细节作用分析阅读理解课件
- (2025年)柘荣县检察官、法官入员额考试真题(附答案)
- 沙石采购管理制度
- 洗化采购工作日常管理制度
- 浙江办公椅采购制度规定
- 消毒药械采购制度
- 润滑油采购制度
- 大平层户型设计方案
- 2025年金融市场基础知识真题及答案
- GB/T 5563-2025橡胶和塑料软管及软管组合件静液压试验方法
- 云南省茶叶出口竞争力分析及提升对策研究
- 基于STM32单片机的智能宠物项圈
- 屠宰企业食品安全知识培训课件
- 卵巢黄体囊肿破裂课件
- 12S522混凝土模块式排水检查井图集
- 民航安全培训课件
- 二级短元音(课件)牛津英语自然拼读
- 入职性格测试题目及答案
评论
0/150
提交评论