Chapter 1: Introduction to SAS

Slides:



Advertisements
Similar presentations
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Advertisements

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.
1 Lab Session-I CSIT120 Spring2001 Using Windows Using An Editor Using Visual C++ Using Compiler Writing and Running Programs Lab-1 continues (Session.
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.
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...
SPSS 1: An Introduction to the Statistical Package SPSS Suzie Cro MRC Clinical Trials Unit.
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.
Lesson No:9 MS-Word Tools, Mail Merge and working with Tables CHBT-01 Basic Micro process & Computer Operation.
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.
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
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
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.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
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.
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
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
1 Introduction to SAS Available at
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.
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 3: Getting Started with Tasks
Chapter 2: The Visual Studio .NET Development Environment
Chapter 5: Enhancing Your Output with ODS
Downloading and Preparing a StudentVoice File for SPSS
2 At the top of the zone in which you want to add the Web Part, click Add a Web Part. In the Add Web Parts to [zone] dialog box, select the check box of.
Practical Office 2007 Chapter 10
2 At the top of the zone in which you want to add the Web Part, click Add a Web Part. In the Add Web Parts to [zone] dialog box, select the check box of.
Introduction to Microsoft Access
An Introduction to Computers and Visual Basic
Introduction to Programming
Jonathan W. Duggins; James Blum NC State University; UNC Wilmington
Chapter 2: Getting Data into SAS
Basic operations in Matlab
3.01 Apply Controls Associated With Visual Studio Form
SAS Programming Introduction to SAS.
Chapter 3: Working With Your Data
Word and the Writing Process
An Introduction to Computers and Visual Basic
OPERATE A WORD PROCESSING APPLICATION (BASIC)
Working with Data in Windows
Instructor: Raul Cruz-Cano
Tamara Arenovich Tony Panzarella
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
Introduction to Programming
Chapters 5 and 7 supplement
Hands-on Introduction to Visual Basic .NET
CIS16 Application Development Programming with Visual Basic
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.
Introduction to Programming
An Introduction to Computers and Visual Basic
Stata Basic Course Lab 2.
JavaScript: Introduction to Scripting
Introduction to Programming
Grauer and Barber Series Microsoft Access Chapter Two
Running a Java Program using Blue Jay.
Instructor: Raul Cruz 9/4/13
Introduction to SAS Lecturer: Chu Bin Lin.
Microsoft Excel 2007 – Level 2
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 © Fall 2011 John Grego and the University of South Carolina

SAS Statements 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 © Fall 2011 John Grego and the University of South Carolina

SAS Comments Rules for SAS comments: Comment “boxes” are popular Comments: Two possible styles *….; or /*….*/ *Here is a comment; /* Here is another comment */ /* could be a control symbol in older languages. © Fall 2011 John Grego and the University of South Carolina

SAS Data Sets Specially formatted “worksheet”; current extension is .sas7bdat Variables represented by Columns 32,767 variables or more Observations represented by Rows Two Data Types; Numeric and Character Default variable length is 8 Run agency.sas Go to WORK.agency and look at worksheet. Two data types, but many data formats (show in Column Attributes).

SAS Variables 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

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, numbers, and underscores Names can contain upper/lower case letters I keep variable names short.

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 Employers are interested in data management skills

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

Steps and Statements Steps may contain many statements Steps usually end when: Another step begins A RUN; statement appears DATA height; ..SAS statements.. run; PROC PRINT DATA=height; PROC REG; Another step (DATA or PROC). There are several less common ways to end a step (quit, etc)

Implicit Looping 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 Order is fungible in SAS data steps (though text indicates otherwise).

Windowing Environment PCs in labs and classrooms use windowing environment. See Sec 1.6-1.12 for information on other SAS environments SAS OnDemand uses Studio, not Display Manager. Enterprise Guide has a project-based windowing environment.

SAS Windows: Right Frame 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 “Results Viewer”: Printable results Other named SAS programs also appear. Results Viewer has supplanted Output.

SAS Windows: Left Frame 3 windows in one frame and 2 windows in another “Results”: Table of contents for Results Viewer window “Explorer”: Icons for file folders, SAS libraries, and SAS data sets Additional output windows (Output, Graphics) I don’t use Results as much as I should. SPSSX has this output layout too. Run agency.sas (if you haven’t already).

Running Programs 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

Log Window 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 info on intermediate datasets can be helpful Open in New Window does not open individual objects…

Results Viewer Window Printing/Saving Output: Directly from Results Viewer window (cut-and-paste to file (Word or Notepad); edit and print; Using Results window (format options are limited)

Output Window Creating Output window: Tools->Options->Preferences->Results Click “Create Listing” Both styles of output will be available

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

Creating 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

SAS Library Locations 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’;

Over-writing a Permanent Data Set 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; Mitchell.anpp may be a base data set for many subsequent data steps, so this write-over is severe.

Viewing Data Sets in Explorer Double-click on a library, then double-click on an available dat a 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.

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;