Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.

Slides:



Advertisements
Similar presentations
The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
Advertisements

Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Chapter 9: Introducing Macro Variables 1 © Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
I OWA S TATE U NIVERSITY Department of Animal Science Modifying and Combing SAS Data Sets (Chapter in the 6 Little SAS Book) Animal Science 500 Lecture.
SAS Programming: Working With Variables. Data Step Manipulations New variables should be created during a Data step Existing variables should be manipulated.
Introduction to SQL Session 2 Retrieving Data From Multiple Tables.
Quick Data Summaries in SAS Start by bringing in data –Use permanent data set for these examples Proc Tabulate –Produces summaries very quickly and easily.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
Chapter 3 Planning Your Solution
Pet Fish and High Cholesterol in the WHI OS: An Analysis Example Joe Larson 5 / 6 / 09.
Access Tutorial 3 Maintaining and Querying a Database
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.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
SAS PROC REPORT PROC TABULATE
Lecture 5 Sorting, Printing, and Summarizing Your Data.
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.
1 Experimental Statistics - week 6 Chapter 15: Randomized Complete Block Design (15.3) Factorial Models (15.5)
PROC REPORT organizes the output in many ways, from the simple to highly complex… PROC REPORT NOWINDOWS HEADLINE HEADSKIP; COLUMN variable-list; DEFINE.
Introduction to SAS Essentials Mastering SAS for Data Analytics
Quantify the Example Data First, code and quantify the data (assign column locations & variable names) Use the sample data to create a data set from the.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
1 Procedures Blocks of code which can be called from anywhere in a program Enable us to avoid needless repetition of the same code Can take parameters.
Knowing Understanding the Basics Writing your own code SAS Lab.
Social Science Research Design and Statistics, 2/e Alfred P. Rovai, Jason D. Baker, and Michael K. Ponton Splitting Files PowerPoint Prepared by Alfred.
SQL Chapter Two. Overview Basic Structure Verifying Statements Specifying Columns Specifying Rows.
1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.
Chapter 22: Using Best Practices 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
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.
Here’s another problem (see section 2.13 on page 54). A file contains two different types of records (say A’s and B’s) and we only want to read in the.
1 EPIB 698C Lecture 4 Raul Cruz-Cano Summer 2012.
Section 3.9: RETAIN & sum statements –because all variables are set to missing at the start of each iteration of the DATA step, we need a statement to.
Chapter 7: Macros in SAS  Macros provide for more flexible programming in SAS  Macros make SAS more “object-oriented”, like R 1 © Fall 2011 John Grego.
FOR MONDAY: Be prepared to hand in a one-page summary of the data you are going to use for your project and your questions to be addressed in the project.
14b. Accessing Data Files in SAS ®. 1 Prerequisites Recommended modules to complete before viewing this module  1. Introduction to the NLTS2 Training.
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.
Chapter 2 Getting Data into SAS Directly enter data into SAS data sets –use the ViewTable window. You can define columns (variables) with the Column Attributes.
Chapter 17 Supplement: Alternatives to IF-THEN/ELSE Processing STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South.
Chapter 8: Using Basic Statistical Procedures “33⅓% of the mice used in the experiment were cured by the test drug; 33⅓% of the test population were unaffected.
Use the SET statement to: –create an exact copy of a SAS dataset –modify an existing SAS dataset by creating new variables, subsetting (using a subsetting.
Chapter 4: Creating List Reports
BMTRY 789 Lecture9: Proc Tabulate Readings – Chapter 11 & Selected SUGI Reading Lab Problems , 11.2 Homework Due Next Week– HW6.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
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
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 Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
03/20161 EPI 5344: Survival Analysis in Epidemiology Estimating S(t) from Cox models March 29, 2016 Dr. N. Birkett, School of Epidemiology, Public Health.
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.
Session 1 Retrieving Data From a Single Table
Chapter 11 Reading SAS Data
Applied Business Forecasting and Regression Analysis
Chapter 6: Modifying and Combining Data Sets
Chapter 3: Working With Your Data
Instructor: Raul Cruz-Cano
Tamara Arenovich Tony Panzarella
Chapter 4: Sorting, Printing, Summarizing
Lab 2 Data Manipulation and Descriptive Stats in R
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.
Quick Data Summaries in SAS
The Linux Command Line Chapter 28
Producing Descriptive Statistics
Introduction to SAS Essentials Mastering SAS for Data Analytics
Presentation transcript:

Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate variables unless you tell SAS otherwise by –changing the DATA= statement –using the WHERE statement or the BY statement –using the VAR statement All PROCs begin with the keyword PROC, followed by the name of the PROC, followed by additional options or statements required by the specific PROC.

Some PROCs we’ve already seen are: –PROC CONTENTS; –PROC PRINT ; –PROC SORT; BY sortingvariablename; –PROC MEANS; –PROC FREQ; TABLES list_of_variables; The BY statement is required with PROC SORT, optional with others... when used with other PROCs it tells SAS to perform separate analyses for each of the values of the BY variables, instead of keeping all the observations together in one group.

Let’s do an example with Dr. Padgett’s dataset...suppose you wanted to analyze the flowering and the number of live leaves of the plants separately for each marsh... PROC SORT ; BY marsh; PROC FREQ; TABLES flower*lleaves; BY marsh; NOTE that I have SORTed the data prior to doing the PROC FREQ BY school... when you do a PROC BY a variable, SAS assumes that the dataset is SORTed BY the variable...so if it’s not already sorted, use PROC SORT to do the sorting...

NOTE also that you may use TITLE, FOOTNOTE, and LABEL statements to enhance your output from any PROC... the syntax is TITLEn ‘...’; and FOOTNOTEn ‘...’; and up to 10 titles and footnotes are allowable. The LABEL statement allows you to give labels to your variable names up to 256 characters long... If you want your labels to be used throughout a dataset, use the label statement in the DATA step - otherwise use it within the PROC step...

The WHERE statement may be used with PROCs to perform the procedure only on certain observations in the dataset, those satisfying the conditions given in the WHERE statement... for example: –in Dr. Padgett’s data, try to PRINT only those flowering plants from the Shell Island marsh: PROC PRINT; WHERE flower=“yes” AND marsh=“si”; Note the similarity with the subsetting IF statements we saw earlier. The same comparison, logical, and arithmetic symbols may be used to construct the condition. See the examples on page

PROC SORT is one of the most useful PROC in SAS. Besides being required to sort data prior to doing other PROCs BY the sorting variable, SORTing is useful in its own right... You may specify as many sorting variables as you like, but be careful to note how the multiple sorts are done... try a SORT of Dr. Padgett’s data first by marsh and then by plant height. What happens if you reverse the order or the sorting variables? Note that you may save the SORTed data in its own dataset using the OUT= statement... otherwise the original dataset is overwritten with the SORTed data...

PROC PRINT is the most widely used PROC and it has great flexibility Some of the options used with PROC PRINT are...: –LABEL - to print w/labels previously assigned –NOOBS - to not print the observation number –ID - to use another variable instead of the OBS –SUM - to sum up particular variables this one is helpful for financial printouts... –VAR - to print specific variables in a certain order –BY - to print the data in sections defined by the BY variable in a previous PROC SORT Example: Get a printout of Dr. Padgett’s data so that we print only the total mass of the plants in groups by the number of live leaves summed up in those groups and using the plant number to identify the observations.

For Monday: –Make sure you understand the material in Chapters 2 and 3 in preparation for the midterm - ask questions if you have them… –Read Chapter 4 up through we’ll discuss FORMATs next time along with writing our own formats with PROC FORMAT