Introduction to SAS BIO 226 – Spring 2009. 2 Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.

Slides:



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

Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Knowing Understanding the Basics Writing your own code part 2 SAS Lab.
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.
SAS Programming: Working With Variables. Data Step Manipulations New variables should be created during a Data step Existing variables should be manipulated.
I OWA S TATE U NIVERSITY Department of Animal Science Getting Started Using SAS Software Animal Science 500 Lecture No. 2.
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
Descriptive Statistics In SAS Exploring Your Data.
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.
Basic And Advanced SAS Programming
Welcome to the Exciting World of ! Lessons to familiarize yourself with.
Pet Fish and High Cholesterol in the WHI OS: An Analysis Example Joe Larson 5 / 6 / 09.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Introduction to SAS Lecture 2 Brian Healy.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Collection and Analysis of Data CPH 608 Spring 2015.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
HPR Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Learning the TSP2: a guide for students at the 国際総合学類筑波大学 RUNNING REGRESSIONS FROM A SPREADSHEET FILE If you are using a network browser to view this program,
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.
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.
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.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
Knowing Understanding the Basics Writing your own code SAS Lab.
SAS lecture - week 31 Some Basics of CQUEST The operating system in the ESC lab (1046) is Linux. The operating system in RW labs (107/109 and 211) is Windows.
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
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
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.
How to start using SAS Tina Tian. The topics An overview of the SAS system Reading raw data/ create SAS data set Combining SAS data sets & Match merging.
Laboratory 1. Introduction to SAS u Statistical Analysis System u Package for –data entry –data manipulation –data storage –data analysis –reporting.
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.
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.
Lecture 3 Topic - Descriptive Procedures Programs 3-4 LSB 4:1-4.4; 4:9:4:11; 8:1-8:5; 5:1-5.2.
SAS Basics. Windows Program Editor Write/edit all your statements here. Log Watch this for any errors in program as it runs. Output Will automatically.
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.
Summer SAS Workshop Lecture 3. Summer SAS Workshop Website
Lesson 8 - Topics Creating SAS datasets from procedures Using ODS and data steps to make reports Using PROC RANK Programs in course notes LSB 4:11;5:3.
SAS Basics. Windows Program Editor Write/edit all your statement here.
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.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
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.
1 Introduction to SAS Available at
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.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
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 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.
Chapter 1: Introduction to SAS
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.
Data Manipulation (with SQL)
Instructor: Raul Cruz 9/4/13
Introduction to SAS Lecturer: Chu Bin Lin.
Introduction to SAS Essentials Mastering SAS for Data Analytics
Presentation transcript:

Introduction to SAS BIO 226 – Spring 2009

2 Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data Basic SAS procedures –The PLOT Procedure –The SORT Procedure –The MEANS Procedure –The UNIVARIATE Procedure –The FREQ Procedure –The CORR Procedure Output in Word document References Practice Slides 3-7 Slides 8-11 Slide 9 Slides Slides Slide 14 Slide 15 Slides Slides 14&18 Slide 18 Slide 19 Slide 20 Slides 21-22

3 The different SAS windows Explorer: contains SAS files and libraries Editor: where you can open or type SAS programs Log: stores details about your SAS session (code run, dataset created, errors...) Results: table of contents for output of programs Output: printed results of SAS programs

4 Basic SAS rules (1) Variable names must: –be one to 32 characters in length –begin with letter (A-Z) or underscore (_) –continue with any combination of number, letters or underscores A variable’s type is either character or numeric Missing values: –missing character data is left blank –missing numeric data is denoted by a period (.)

5 Basic SAS rules (2) Two ways to make comments: – * write comment here; – /* write comment here */ SAS is insensitive to case

6 Basic programming rules (1) SAS programs are composed of statements: these are organized in DATA steps and PROC steps –DATA step: gives dataset a name, manipulates dataset –PROC step: procedure or analysis you want SAS to carry out SAS reads code line by line and the end of a line is marked by a semicolon. All SAS programs end with RUN; Quotes can be single or double.

7 Basic programming rules (2) SAS statements are free-format: –Can begin and end in any column –One statement can continue over several lines –Several statements can be on one line To submit program, highlight the code to run and click on the submit button (running silhouette)

8 Loading data If you have SAS data set (sasintro.sas7bdat) you can double click on it and it will load itself. If you don’t have SAS data set (sasintro.txt), and the first row of your dataset contains the variable names, you can import it using File > Import Data… and specify the directory. Or you can use the following code: DATA mydata; INFILE ‘g:\shared\bio226\sasintro.txt’; INPUT weight bmi id $ age activity education smoking; RUN; Setting your current directory: on the bottom line of the main SAS window, you should see it set to C:\WINDOWS\system32. Double click on it to change it.

9 How to view the loaded data? Go in the Explorer window, double click on Libraries, then Work and sasintro.sas7bdat Use the PRINT procedure to view the first 10 records: PROC PRINT DATA=mydata (OBS=10); RUN; To view general information about the data set, like variables’ name and type: PROC CONTENTS DATA=mydata; RUN;

10 Variables from sasintro.txt #VariableTypeUnit 5activityNumkcal/week 4ageNumyears 2bmiNumkg/m 2 6educationNumyears 3idChar 7smokingNum1:current smoker, 0:non-smoker 1weightNumlbs

11 /* Libraries */ A library is the directory where your SAS dataset is stored. The default library is named Work and stores your SAS datasets temporarily: they will be deleted when you end your SAS session If you want to save your SAS datasets and use them again later, create your own library: LIBNAME SAS_Lab 'p:\BIO226\SAS'; DATA SAS_Lab.mydata; INFILE ‘g:\shared\bio226\sasintro.txt’; INPUT weight bmi id $ age activity education smoking; RUN;

12 Manipulating data (1) selecting a subset of rows DATA mydata_s; SET mydata; IF smoking=1; RUN; deleting a column (or columns) DATA mydata2; SET mydata; DROP weight education; RUN;

13 Manipulating data (2) adding a column (or columns) DATA mydata3; SET mydata; weight_kg=weight*0.453; IF age <= 60 THEN agegroup=1; ELSE IF age<=70 THEN agegroup=2; ELSE agegroup=3; /*drop age;*/ RUN;

14 Basic procedures: plots Barcharts PROC CHART DATA=mydata3; VBAR agegroup /DISCRETE; RUN; Scatterplot PROC PLOT DATA=mydata3; PLOT bmi*weight='*'; RUN; Histogram, Boxplot, Normal Probability Plot PROC UNIVARIATE DATA=mydata3 PLOT; VAR weight; RUN;

15 Basic procedures: sorting data PROC SORT DATA=mydata OUT=mydata4; BY age weight; PROC PRINT DATA=mydata (OBS=5); PROC PRINT DATA=mydata4 (OBS=5); RUN;

16 Summarizing data (1) Summarizing weight: PROC MEANS DATA=mydata; VAR weight; RUN; Summarizing weight in the youngest agegroup: PROC MEANS DATA=mydata3; VAR weight; WHERE agegroup=1; RUN;

17 Summarizing data (2) Summarizing weight by smoking status (two possible codes): PROC SORT DATA=mydata OUT=mydata5; BY smoking; PROC MEANS DATA=mydata5; VAR weight; BY smoking; RUN; PROC MEANS DATA=mydata; CLASS smoking; VAR weight; RUN; All these summarizing measures can be obtained with PROC UNIVARIATE also.

18 Categorical data and correlation Summarizing categorical data PROC FREQ DATA=mydata3; TABLES smoking*agegroup /chisq exact; RUN; Examining correlation PROC CORR DATA=mydata; VAR weight; WITH bmi age; RUN;

19 SAS output and Word To send you SAS output to a Word document: ODS RTF FILE=‘p:output.RTF’ style=minimal; PROC CORR DATA =mydata; VAR weight; WITH bmi age; RUN; ODS RTF CLOSE; Other styles: Journal, Analysis, Statistical

20 For further references SAS9 Documentation on the Web: The Little SAS Book, L.D. Delwiche and S.J. Slaughter See SAS_help.doc on course website

21 Try your own Find the summary statistics (mean, mode, standard deviation,…) for education with PROC UNIVARIATE, as well as a histogram for years of education. Create a new variable educ_group which breaks years of education into four groups (0-10, 10-15,15-18,18-25). Put this new variable in a new data set and drop the education variable, as well as weight, bmi and age. Find the number of smokers per education group. Find the mean physical activity in each education group.

22 Data nameDescription mydataoriginal imported data mydata_sonly smokers mydata2dropped weight, education mydata3added weight_kg, agegroup, dropped age mydata4sorted original data by age and weight mydata5sorted original data by smoking status Recap of different datasets created