Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2

Slides:



Advertisements
Similar presentations
Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Advertisements

Introducing JavaScript
The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
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.
Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training.
The Web Warrior Guide to Web Design Technologies
Statistics in Science  Introducing SAS ® software Acknowlegements to David Williams Caroline Brophy.
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
Biostatistical Methods II PubH 6415 Spring PubH 6415 – Biostatistics I Instructor: Susan Telke (office hours: lecture.
Developing Effective Reports
Introduction to SQL Session 1 Retrieving Data From a Single Table.
Basic And Advanced SAS Programming
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Welcome to the Exciting World of ! Lessons to familiarize yourself with.
1 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.
Creating SAS® Data Sets
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Developing Effective Reports
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.
Copyright © 2006, SAS Institute Inc. All rights reserved. Enterprise Guide 4.2 : A Primer SHRUG : Spring 2010 Presented by: Josée Ranger-Lacroix SAS Institute.
© Dominion 2003 SAS Certification Made Quick & Easy Virginia SAS Users Group (VASUG) 03/23/2010 Mehrubon Safaraliev SAS Certified Advanced Programmer for.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Chapter 9 Producing Descriptive Statistics PROC MEANS; Summarize descriptive statistics for continuous numeric variables. PROC FREQ; Summarize frequency.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
BMTRY 789 Introduction to SAS Programming Lecturer: Annie N. Simpson, MSc.
1 JavaScript in Context. Server-Side Programming.
Knowing Understanding the Basics Writing your own code SAS Lab.
5/30/2010 SAS Macro Language Group 6 Pradnya Nimkar, Li Lin, Linsong Zhang & Loc Tran.
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.
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.
Introduction to SAS Macros Center for Statistical Consulting Short Course April 15, 2004.
Priya Ramaswami Janssen R&D US. Advantages of PROC REPORT -Very powerful -Perform lists, subsets, statistics, computations, formatting within one procedure.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Summer SAS Workshop Lecture 3. Summer SAS Workshop Website
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
1 JavaScript in Context. Server-Side Programming.
An Introduction Katherine Nicholas & Liqiong Fan.
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.
FORMAT statements can be used to change the look of your output –if FORMAT is in the DATA step, then the formats are permanent and stored with the dataset.
1 Chapter 3: Getting Started with Tasks 3.1 Introduction to Task Dialogs 3.2 Creating a Listing Report 3.3 Creating a Frequency Report 3.4 Creating a Two-Way.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
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.
Online Programming| Online Training| Real Time Projects | Certifications |Online Classes| Corporate Training |Jobs| CONTACT US: STANSYS SOFTWARE SOLUTIONS.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapter 26 By Tasha Chapman, Oregon Health Authority.
The Urban Institute - SAS Training6/9/20161 SAS Training This SAS Training Course was designed to introduce users at The Urban Institute to SAS programming.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapter 25 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 16 & 17 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
LMEvents SharePoint Portal How-to Guide
SAS Programming Introduction to SAS.
Tamara Arenovich Tony Panzarella
Defining and Calling a Macro
Instructor: Raul Cruz 9/4/13
Presentation transcript:

Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2 By Tasha Chapman, Oregon Health Authority

About these trainings

What is SAS? Began as a statistical package Also allows users to: Store data Manipulate data Create reports PDF Excel HTML XML RTF / Word Etc. Etc. Etc.

What is SAS? Also allows users to: Create graphs Create maps Send e-mails Create web applications Create iPhone Apps Access R Schedule regularly run reports Etc. Etc. Etc.

About these trainings Created by Tasha Chapman Originally held in early 2013 Examples created using SAS version 9.2

About these trainings Material based on Learning SAS by Example: A Programmer’s Guide by Ron Cody Book is available for state employees using Books 24x7 through the Oregon State Library Sample code and data files from the book can be found: http://support.sas.com/publishing/authors/extras/60864_code.pdf Some slides will have a book icon at the corner of the slide with a hyperlink to additional text

Training schedule Basic Data Manipulation Week 1: Chapters 1 & 2 Introduction to SAS Week 2: Chapters 3 & 4 (except 3.9 through 3.14) Creating permanent SAS datasets SAS Libraries Reading raw data from external files Proc Print / Proc Contents 

Training schedule Basic Data Manipulation (cont.) Week 3: Chapters 5 & 6 (and 3.9 through 3.14) Creating formats and labels Reading and writing data from an Excel spreadsheet Proc Import with a twist Proc Datasets Week 4: Chapters 7 & 10 (except 10.6, 10.13) Conditional processing Subsetting and combining SAS datasets

Training schedule Basic Data Manipulation (cont.) Week 5: Chapters 9, 11, & 12 (and 10.13) Working with dates About SAS Date, Time, and Datetime values Anydate informat Working with numeric functions Working with character functions Put and Input

Training schedule Basic Reporting Week 6: Chapters 14 & 19 Displaying your data (PROC Print) Global statements (titles, footnotes, system options) Introducing the Output Delivery System  Week 7: Chapters 16 & 17 (and 10.6) Summarizing your data (PROC Means) Counting frequencies (PROC Freq)

Training schedule Basic Reporting (cont.) Week 8: Chapter 15 Creating customized reports (PROC Report) Week 9: Chapter 18 Creating Tabular Reports (PROC Tabulate)

Training schedule Advanced Topics Week 10: Chapter 26 Introduction to SQL Week 11: Chapters 8, 13 & 24 Iterative processing and looping Working with multiple observations per subject By group processing Working with arrays

Training schedule Advanced Topics (cont.) Week 12: Chapter 25 Introduction to SAS Macro Language %LET CALL SYMPUT Week 13: Chapter 20 Generating high quality graphics

Training schedule Advanced Topics (cont.) Week 14: Chapters 21, 22 & 23 The Leftovers! Restructuring SAS datasets (PROC Transpose) Using advanced features of user-defined formats and informats Using advanced input techniques Saving and storing macros

SAS Display Manager

Details about jobs you’ve run, including error messages Log: Details about jobs you’ve run, including error messages Explorer Window: See libraries and SAS datasets Enhanced Editor: Where you write your SAS code

List of previously run results Results tab: List of previously run results Output Window: Basic view of results and output (Also known as “Listing Destination”)

Run: Submits your SAS code (“The Running Man”)

You can submit the program as a whole or Run only a portion of highlighted code

Chunks of code will be processed in the order you RUN them, not necessarily in the order you wrote them

The elements of a SAS program

Read and write data, manipulate data, perform calculations, etc. DATA steps: Read and write data, manipulate data, perform calculations, etc. Every DATA step creates a new dataset

Every SAS program can have multiple DATA and PROC steps Produce reports, summarize data, sort data, create formats, generate graphs, etc. etc. etc.

Titles, Footnotes, Options, Macros, Libname Global statements: Remain in effect until changed by another global statement or SAS session ends Examples: Titles, Footnotes, Options, Macros, Libname

/* comment statement */ Comment statements: Ignored by SAS when code is run Used to write comments to yourself or others or comment out code you don’t want to run *comment statement; or /* comment statement */

Programming in SAS SAS is generally forgiving Code can be written on a single line or multiple lines Code and variable names not case sensitive Even accepts some misspellings Fi The Doo Semicolons are super important Colors of Enhanced Editor Always check your log!!! Often many ways to do the same thing

DATA step examples

DATA step examples

DATA step examples DATA demographic “DATA demographic” creates a dataset called “Demographic” Infile statement reads the text file with the data Input statement tells SAS what to name the new variables. $ sign after “Gender” indicates that this is a character variable. The remaining variables are numeric.

DATA step examples DATA newdemo “DATA newdemo” creates a dataset called “newdemo” “SET demographic” references the previous dataset “demographic” as the basis for the new dataset “BMI =” creates a new variable called “BMI” that is calculated as shown. This is called an assignment statement.

PROC step examples

PROC step examples

PROC step examples PROC freq Creates a basic frequency table with: Percent Cumulative Frequency Cumulative Percent “DATA=newdemo” references the newdemo dataset TABLE statement indicates which variable(s) to include Can use multiple variables and even create cross-tab tables

PROC step examples PROC means Creates a basic summary table with: N Std Dev Minimum Maximum Can specify which statistics to use in table “DATA=newdemo” references the newdemo dataset VAR statement indicates which variable(s) to include

Good SAS programmers use EXPLICIT step boundaries Other notes Step boundaries: Each step is executed when a step boundary is encountered Explicit step boundary: RUN or QUIT statement Implicit step boundary: Beginning of a new PROC or DATA step Good SAS programmers use EXPLICIT step boundaries

Good SAS programmers use EXPLICIT dataset references Other notes Referencing datasets: Most procedures and DATA steps reference an existing dataset Explicit dataset reference: DATA= or SET statement Implicit dataset reference: If not explicitly referenced, SAS will use the last referenced dataset Good SAS programmers use EXPLICIT dataset references

SAS Help

Where to learn more about SAS Technical papers SAS User Groups Websites Books Classes http://www.sascommunity.org/wiki/ Learning_SAS_-_Resources_You_Can’t_Live_Without Popular Websites

www.google.com Popular Websites

www.ats.ucla.edu/stat/sas Popular Websites

www.ats.ucla.edu/stat/sas Explains both the stats and the SAS code Popular Websites

www.lexjansen.com Popular Websites

SAS Help and Documentation Popular Websites

How to read SAS Documentation DATA output-SAS-data-set (DROP=variable(s) | KEEP=variable(s)); SET SAS-data-set <options>; BY variable(s); RUN;

How to read SAS Documentation DATA output-SAS-data-set (DROP=variable(s) | KEEP=variable(s)); SET SAS-data-set <options>; BY variable(s); RUN; DATA, DROP=, KEEP=, SET, BY, and RUN are in uppercase bold because they must be spelled as shown.

How to read SAS Documentation DATA output-SAS-data-set (DROP=variable(s) | KEEP=variable(s)); SET SAS-data-set <options>; BY variable(s); RUN; output-SAS-data-set, variable(s), SAS-data-set, and options are in italics because each represents a value that you supply.

How to read SAS Documentation DATA output-SAS-data-set (DROP=variable(s) | KEEP=variable(s)); SET SAS-data-set <options>; BY variable(s); RUN; <options> is enclosed in angle brackets because it is optional syntax.

How to read SAS Documentation DATA output-SAS-data-set (DROP=variable(s) | KEEP=variable(s)); SET SAS-data-set <options>; BY variable(s); RUN; DROP= and KEEP= are separated by a vertical bar ( | ) to indicate that they are mutually exclusive.

Sample datasets

R:\Training\SAS\Learning SAS by Example (Cody)\60864 Original zip file in: R:\Training\SAS\Learning SAS by Example (Cody)\60864

Permanent location of all SAS Datasets Text and CSV: Text and CSV data files used to create the SAS Datasets

For next week… Read chapters 3 & 4 (skip sections 3.9 through 3.14)