Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in.

Slides:



Advertisements
Similar presentations
How to Import an Excel File Using the SAS Import Wizard SAS 9 for Windows.
Advertisements

Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Creating and Editing a Web Page Using Inline Styles
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.
Tutorial 8: Developing an Excel Application
Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training.
Statistics in Science  Introducing SAS ® software Acknowlegements to David Williams Caroline Brophy.
1 An Introduction to IBM SPSS PSY450 Experimental Psychology Dr. Dwight Hennessy.
Macros Excel built-in functions are great but limited Macros are a means for the user to define new functions A macro is a single command that automates.
Chapter 1: Getting Started Overview of basic components Data Sets Data Steps Windowing (DM) environment Submitting programs Reviewing Output System options.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
A Visual Introduction to PC SAS. Start SAS by double-clicking on the SAS icon...
Welcome to the Exciting World of ! Lessons to familiarize yourself with.
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
Chapter 18: Modifying SAS Data Sets and Tracking Changes 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Creating SAS® Data Sets
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
11 Chapter 3: Getting Started with Tasks 3.1 Introduction to Tasks and Wizards 3.2 Creating a Frequency Report 3.3 Generating HTML, PDF, and RTF Output.
Chapter 2: Working with Data in a Project
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Creating a Web Site to Gather Data and Conduct Research.
A Brief Introduction to Stata(1). 1. Getting Started.
General Systems Information ALEPH v20.01 Library Staff Training © South Dakota Library Network, 2013 ©Ex Libris (USA), 2011 Modified for SDLN Version
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Knowing Understanding the Basics Writing your own code SAS Lab.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
Introduction to SAS Essentials Mastering SAS for Data Analytics
1 A Guide to SQL Chapter 2. 2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation.
HTML Concepts and Techniques Fifth Edition Chapter 6 Using Frames in a Web Site.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
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.
Practical PC, 7 th Edition Chapter 4: File Basics.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
1 PL\SQL Dev Templates. 2 TEMPLATE DEFINITION Whenever you create a new program unit, its initial contents are based upon a template which contains pre-defined.
Fall 2003Sylnovie Merchant, Ph.D. ACCESS Tutorial Note: The purpose of this tutorial is to provide an introduction to some of the functions of ACCESS in.
1 Introduction to SAS Available at
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS Essentials - Elliott & Woodward1.
1 Chapter 7: Customizing and Organizing Project Results 7.1 Combining Results 7.2 Updating Results 7.3 Customizing the Output Style (Self-Study)
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Landscaper 101. Time Code AMC AMCNET HELP!!! Where do you go for help? –Upper right corner has a ? for the online help –This presentation.
Creating and Editing a Web Page
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
1 Introduction to SAS Available at
Creating and Editing a Web Page Using Inline Styles
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.
Learning SAS Dr. Chaitali Basu Mukherji. What is SAS? SAS software started out in 1970s as a software package for statistical analysis By mid-1980s SAS.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
3 A Guide to MySQL.
Chapter 5: Enhancing Your Output with ODS
* 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
Instructor: Raul Cruz-Cano
Tamara Arenovich Tony Panzarella
Chapters 5 and 7 supplement
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.
An Introduction to Computers and Visual Basic
Instructor: Raul Cruz 9/4/13
Presentation transcript:

Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in a semicolon –Upper/lower case does not matter in SAS 1 © Fall 2011 John Grego and the University of South Carolina

Chapter 1: Introduction to SAS  Rules for SAS statements: –Statements can continue on next line –Statements can be on same line as other statements –Statements can start in any column 2 © Fall 2011 John Grego and the University of South Carolina

Chapter 1: Introduction to SAS  Rules for SAS comments:  Comment “boxes” are popular  Comments: Two possible styles  *….; or /*….*/ *Here is a comment; /* Here is another comment */ 3 © Fall 2011 John Grego and the University of South Carolina

SAS Data Sets  Specially formatted “worksheet”; current extension is.sas7bdat  Variables represented by Columns  Observations represented by Rows  Two Data Types; Numeric and Character  Default variable length is 8 4

SAS Data Sets  Choose data type based on how you use the variable  Example: SSN could be character  Missing data in SAS is denoted by a period (.) for numeric data and a null space for character data  Variable attributes (Type, Length, etc) are stored with the SAS data set 5

Rules for Naming SAS variables  Names can be 32 characters or fewer  Names must begin with a letter or underscore (_)  Names may contain only letters, number, and underscores  Names can contain upper/lower case letters 6

Two Parts to SAS Programs DATA step:  When ads ask for “SAS experience”, they mean experience with the DATA step  Begins with DATA statements  Reads in and modifies data  Creates SAS data set 7

Two Parts to SAS Programs PROC step:  Begins with PROC statements  Performs (statistical) analyses on data  Produces results/outputs 8

Two Parts to SAS Programs  Steps may contain many statements  Steps usually end when: 1.Another step begins 2.A RUN; statement appears DATA height;..SAS statements.. run; PROC PRINT DATA=height; run; PROC REG;..SAS statements.. run; 9

Two Parts to SAS Programs  SAS reads data sets one observation at a time-implicit looping  SAS executes steps line by line  Be sure to enter statements in correct order 10

Windowing Environment  PCs in labs and classrooms use windowing environment.  See Sec 1.5 for information on other SAS environments 11

SAS Windows  3 windows in one frame and 2 windows in another  “Editor”: Type in and edit SAS programs in the editor window (color-coded)  “Log”: Contains notes about SAS code execution, SAS data sets, and errors/warnings  “Output”: Printable results 12

SAS Windows  3 windows in one frame and 2 windows in another  “Results”: Table of contents for Output window  “Explorer”: Icons for file folders, SAS libraries, and SAS data sets  Additional output windows (HTML format, Graphics) 13

Windowing Environment  Once program is entered into “Editor”, save it, then choose “Submit” under “Run” menu (Or “make the little man run”)  Go to Output and Log windows for results or notes  If program disappears, choose “Recall Last Submit” under “Run” menu 14

Windowing Environment  In any window: Choose “Edit”->”Clear All” by right-clicking to clear window (Output and Log windows can get cluttered)  Log window -> Error messages, number of observations and variables created. Often hard to interpret, but into on intermediate datasets can be helpful 15

Windowing Environment Printing/Saving Output:  Directly from Output window (too many page breaks—wastes paper)  Using Results window (can print/save partial output—right click; select “Open in New Window”)  Copy to file (Word or Notepad); edit and print. 16

Windowing Environment Creating HTML Output:  Tools->Options/Preferences  Click “Create HTML”  Both styles of output will be available 17

SAS Libraries Location where SAS data sets and SAS files are stored Location where SAS data sets and SAS files are stored Often, an ordinary directory that contains non-SAS files as well Often, an ordinary directory that contains non-SAS files as well Built-in libraries: Sashelp, Sasuser, Work (default library) Built-in libraries: Sashelp, Sasuser, Work (default library) 18

SAS Libraries Creating Libraries:  In active Libraries windows, select File- >New, or right click and select New  Use method in Section 1.11, or select the sparkly file cabinet drawer Name:  Libref (8 characters or fewer)  Path (location for data sets to be stored)  Enable at start-up 19

SAS Libraries  Library location can easily be forgotten (if not enabled)  SAS prompts you to save in a separate file the code that created the library  It’s convenient to include simple code at the top of your file: libname mitchell ‘z:\stat 540\Mitchell’; 20

SAS Libraries Be careful that you do not write over a saved file: /* This code stores a data set from WORK in MITCHELL */ /* It can also accidentally overwrite any changes in mitchell.anpp in subsequent runs */ libname mitchell ‘z:\stat 540\mitchell’; data mitchell.ANPP; set ANPP; 21

Viewing Data Sets in Explorer  Double-click on a library, then double-click on an available data set (e.g, “Class” in Sashelp) or right-click and select Properties.  Close window when finished examining data set  Examine data set worksheet for problems  Right-click on column label and select “Column attributes” to obtain info on the variable in the data set. 22

SAS System Options  OPTIONS statement can appear before the DATA statement  Frequently used to improve pagination and on-screen readabililty of output  OPTIONS LINESIZE=80 NOCENTER NODATE PAGESIZE=64 NONUMBER; 23