Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training.

Slides:



Advertisements
Similar presentations
Effecting Efficiency Effortlessly Daniel Carden, Quanticate.
Advertisements

The SAS ® System Additional Information on Statistical Analysis Programming.
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
The Web Warrior Guide to Web Design Technologies
Statistics in Science  Introducing SAS ® software Acknowlegements to David Williams Caroline Brophy.
MODULE 4 File and Folder Management. Creating file and folder A computer file is a resource for storing information, which is available to a computer.
2440: 211 Interactive Web Programming JavaScript Fundamentals.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
1 Computer Applications in Epidemiology Dongmei Li Lecture 26 5/6/2009.
Copyright © 2006, SAS Institute Inc. All rights reserved. Shortcuts- what you may not know that can save you time! Elizabeth Ceranowski SAS Student Programs.
Introduction to SPSS (For SPSS Version 16.0)
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS Essentials - Elliott & Woodward1.
Into to SAS ®. 2 List the components of a SAS program. Open an existing SAS program and run it. Objectives.
Creating SAS® Data Sets
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Chapter 2 Software Tools and Assembly Language Syntax.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
1 Experimental Statistics - week 2 Review: 2-sample t-tests paired t-tests Thursday: Meet in 15 Clements!! Bring Cody and Smith book.
Math 3400 Computer Applications of Statistics Lecture 1 Introduction and SAS Overview.
SAS 介绍和举例 Presented by 经济实验教学中心 商务数据挖掘中心. Raw Data Read in Data Process Data (Create new variables) Output Data (Create SAS Dataset) Analyze Data Using.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
CSE 1301 Lecture 2 Data Types Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Knowing Understanding the Basics Writing your own code SAS Lab.
Bringing Data into SAS From Menu: –File –Import Data –Spreadsheet example first Pick file by browsing Select Library and Member (we will talk about this.
Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in.
Introduction to SAS Essentials Mastering SAS for Data Analytics
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
1 Chapter 2: Working with Data in a Project 2.1 Introduction to Tabular Data 2.2 Accessing Local Data 2.3 Accessing Remote Data 2.4 Importing Text Files.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Laboratory 1. Introduction to SAS u Statistical Analysis System u Package for –data entry –data manipulation –data storage –data analysis –reporting.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS Essentials - Elliott & Woodward1.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
ISQS 6347, Data & Text Mining 1 ISQS 6339, Data Management & Business Intelligence Data Preparation for Analytics Using SAS Zhangxi Lin Texas Tech University.
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
1 Introduction to SAS Available at
Chapter 21: Controlling Data Storage Space 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Chapter 6 JavaScript: Introduction to Scripting
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Chapter 2: Getting Data into SAS
SAS Programming Introduction to SAS.
Chapter 1: Introduction to SAS
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Instructor: Raul Cruz-Cano
Tamara Arenovich Tony Panzarella
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.
JavaScript: Introduction to Scripting
Instructor: Raul Cruz 9/4/13
Introduction to MATLAB
Introduction to SAS Essentials Mastering SAS for Data Analytics
Presentation transcript:

Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training

SAS Datasets Examining the structure of SAS Datasets

SAS Data Sets Two Sections Descriptor Section Data Section

Data Set Descriptor Section

SAS Data Section

Attributes of Variables Name e.g. Status Type Numeric or Character e.g. Status in this example is character (T, TT, PT, or NTT) and Satisfaction is numeric (1 to 5).

SAS Data Set Terminology Variables – columns in a SAS data set. Observations – rows in a SAS data set. Numeric Data – values that are treated as numeric and may include 8 bytes of floating storage for 16 to 17 significant digits. Character Data – non numeric data values such as letters, numbers, special characters, and blanks. May be stores with a length of 1 to 32, 767 bytes. One byte is equal to one character.

SAS Data Set and Variable Name Criteria Can be 32 characters long. Can be uppercase, lowercase, or a mixture of the cases. Are not case sensitive Cannot start with number and cannot contain special characters or blanks. Must start with a letter or underscore.

SAS Dates Dates are treated as special kind of numeric data. They are the number of days since January 1 st, January 1 st 1960 is the 0 point. SAS dates can go back to 1582 (Gregorian Calendar) and forward to the year Dates are displayed using a format. There are a number of different date formats supported by SAS. Time is scored as the number of seconds since midnight. SAS date time is the number of seconds since January 1 st, 1960.

Missing Data in SAS Missing values are valid values. For character data, missing values are displayed as blanks. For numeric data, missing values are displayed as periods.

SAS Syntax

Statements in SAS are like sentences. The punctuation though is a semicolon( ; )rather than a period (. ) Most Statements (but not all) start with an identifying key word (e.g. proc, data, label, options, format…) Statements are strung together into sections similar to paragraphs. These paragraphs in a Windows OS are ended with the word “run” and a semicolon.

Example of SAS Syntax

SAS Syntax Rules SAS statements are format free. One or more blanks or special characters are used to separate words. They can begin and end in any column. A single statement can span multiple lines. Several statements can be on the same line.

Example of SAS Free Format Using the free-format Syntax rules of SAS though can make it difficult for others (or you) to read your program. This is akin to writing a page of text with little attention to line breaks. You may still have Capital letters and periods, but where a sentence begins and ends may be a bit confusing.

Example of SAS Formatted Using the free-format Syntax rules of SAS though can make it difficult for others (or you) to read your program. This is akin to writing a page of text with little attention to line breaks. You may still have capital letters and periods, but where a sentence begins and ends may be a bit confusing. Isn’t this paragraph a bit easier to read?

SAS Comments Type /* to begin a comment. Type your comment text. Type */ to end the comment. Or, type an * at the beginning of a line. Everything between the * and the ; will be commented. e.g. *infile ‘tutor.dat’; Alternatively, highlight the text that you would like to comment and use the keys Ctrl / to comment the line. To uncomment a line, highlight and use the Ctrl Shift / keys.

SAS Comments

SAS Windows

Log Editor Explorer

Enhanced Editor Window Your program script appears in this window. You can either bring it in from a file or type the program right into the window. Once the program is in the window, you can Click Submit (or the running guy). Enhanced Editor Output

SAS Log SAS Log provides a “blow by blow” account of the execution of your program. It includes how many observations were read and output, as well as, errors and notes. Note the errors in red.

Output Window

SAS Library SAS Data Libraries are like drawers in a filing cabinet. The SAS data sets are files within those drawers. Note the icons for the SAS library match that metaphor. In order to assign a “drawer”, you assign a library reference name (libref). There are two drawers already in your library: work (temporary) and sasuser (permanent). You can also create your own libraries (drawers) using the libname statement.

Establishing the libname libname Tina ‘E:\Trainings\JMP Training’; run; Type the libname command in the Enhanced Editor. Click on the running icon

Viewtable Window

Proc Reg Proc reg data= Tina.hsb2; Model write = read / clb; Run;

Proc Univariate