Summer SAS Workshop Lecture 2. Summer 20072 Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic.

Slides:



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

SAS Programming:File Merging and Manipulation. Reading External Files (review) data barf; * create the dataset BARF; infile ’s:\mysas\Table7.1'; * open.
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
The Information Delivery Process Data In Information Out ManageOrganizeExploit.
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.
MR2300: MARKETING RESEARCH PAUL TILLEY Unit 10: Basic Data Analysis.
1 SAS SAS is a statistics software package developed by SAS Institute Inc. in U.S.A. SAS products include SAS/STAT, SAS/IML, SAS/OR, etc. The most.
Basic Concept of Data Coding Codes, Variables, and File Structures.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS Essentials - Elliott & Woodward1.
Creating SAS® Data Sets
Data Cleaning 101 Ron Cody, Ed.D Robert Wood Johnson Medical School Piscataway, NJ.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
Week 3 Topic - Descriptive Procedures Program 3 in course notes Cody & Smith (Chapter 2)
STAT 3130 Statistical Methods II Missing Data and Imputation.
Lecture 5 Sorting, Printing, and Summarizing Your Data.
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 BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
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 Lecture 3: Categorical Data and Dates Readings – Chapter 3 & 4 Lab Problems 3.1, 3.2, 3.19, 4.1, 4.3, 4.5 Homework – HW 2 Book Problems Due 6/24!
PREPARING DATA FOR STATISTICAL ANALYSIS Data Cleaning Data Cleaning Dataset Preparation Dataset Preparation Documentation Documentation 9 September 2008.
Lesson 5 - Topics Formatting Output Working with Dates Reading: LSB:3:8-9; 4:1,5-7; 5:1-4.
SAS 介绍和举例 Presented by 经济实验教学中心 商务数据挖掘中心. Raw Data Read in Data Process Data (Create new variables) Output Data (Create SAS Dataset) Analyze Data Using.
BMTRY 789 Introduction to SAS Programming Lecturer: Annie N. Simpson, MSc.
EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.
Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in.
BMTRY 789 Lecture 2 SAS Syntax, entering raw data, etc. Lecturer: Annie N. Simpson, MSc. Readings – Chapters 1, 2, 12, & 13 Lab Problems 1.1, 1.2, 1.3,
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
Describing Quantitative Data Numerically Symmetric Distributions Mean, Variance, and Standard Deviation.
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
Lesson 6 - Topics Reading SAS datasets Subsetting SAS datasets Merging SAS datasets.
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.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
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.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
Chapter 17: Formatting Data 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
SAS for Data Management and Analysis
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.
LISA SHORT COURSE SERIES: INTRODUCTION TO SAS UNIVERSITY William DeShong Fall 2015.
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.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
BMTRY 789 Lecture9: Proc Tabulate Readings – Chapter 11 & Selected SUGI Reading Lab Problems , 11.2 Homework Due Next Week– HW6.
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.
1 Checking Data with the PRINT and FREQ Procedures.
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
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 Certification Prep Guide Chapter 7 Creating and Applying User-Defined Formats.
Longitudinal Data Techniques: Looking Across Observations Ronald Cody, Ed.D., Robert Wood Johnson Medical School.
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
Applied Business Forecasting and Regression Analysis
Chapter 2: Getting Data into SAS
SAS Programming Introduction to SAS.
Instructor: Raul Cruz-Cano
Producing Descriptive Statistics
Let’s continue to review some of the statistics you’ve learned in your first class: Bivariate analyses (two variables measured at a time on each observation)
Instructor: Raul Cruz 9/4/13
Presentation transcript:

Summer SAS Workshop Lecture 2

Summer Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic operations in SAS? Proc Means Proc Freq Proc Print Title Statements Libname Quiz More Practice!

Summer Part I of Lecture 2 The DATA Step Getting Data into SAS Libname Review Adding variables…doing arithmetic SAS Dates

Summer Get to know your data Before you do anything, review what format your data is in currently. Look at the number and type of variables, and number of observations (rows) you have in your data set(s). KNOW YOUR DATA! Before you can analyze your data with SAS software, your data must be in a form that SAS can read What are some ways to get data ready to analyze in SAS?

Summer What kind of data do you have? 1. Data that is already in the form of a SAS data set. Can right away be used for direct manipulation and analysis 2. Large files of external raw (non-SAS) data. Use Import functions, database copy software (ex: DBMSCopy), or other ways Small pieces of data that are not yet in a SAS data set. (What we have been doing so far-Internal Data) Enter as raw data directly into your Data Step (Keywords INPUT and CARDS)

Summer ) If you already have SAS data sets If you already have SAS data sets, first set up a library statement pointing to where your data is located. Libname heart ‘C:\DATA’; Next start using the data sets directly. Data icd9HF; Set heart.meps; If icd9 = 123.6; Run; Proc Freq Data = icd9HF; *Produce frequencies for Heart Failure patients by gender and race variables; Tables gender race; Run;

Summer Temporary vs. Permanent SAS Data Sets A two level name…a Temporary SAS data set is the one level name that we have been using: LibraryName.DataSetName Temporary SAS data sets will not exist when you shut down the instance of SAS in which they were created. Data new; Set AIDS; Run; First define a SAS Library (Libref)

Summer LIBNAME Statement Use this statement to define your SAS Library location before using your SAS data sets Example: LIBNAME ABC ‘C:\SASDATA’; Proc Means Data = ABC.EX4A; Var X Y Z; Run;

Summer INPUT statement example Data one; Input Name$ Bdate mmddyy10. Age Index; cards; Ann 04/22/ Cathy 08/06/ Rebecca 11/12/ ; Run; *Reading internal data to create SAS data set ‘one’;

Summer SAS Dates A SAS date is the number of days since January 1, 1960 DateSAS date value January 1, January 1, January 1, January 1,

Summer Formatting Dates Informats – To read variables that are dates, you use formatted style input INPUT BirthDate MMDDYY10. Formats – If you print SAS date values, SAS will by default print the actual value, the number of days since January 1, The Format statement below tells SAS to print the variable BirthDate using the DDMMYY8. Format Format BirthDate DDMMYY8.

Summer Why are SAS dates done this way? SAS can use the SAS date to calculate many important things, just as it would any other numeric variable. AGE = INT ((ADMIT – DOB) / ); (Calculates patient age at admission) LEN_STAY = DISCHRG – ADMIT +1; (Calculates the length of stay including the admission day and the discharge day)

Summer Lets Try this… Go to the website and unzip the Clinical2 SAS data file into your C:\DATA folder. Follow the steps (see slide 6) to make a copy of the data as a temporary SAS data set. Create a new variable from the HBeats variable (heart beats per 10 second count). Create and HR variable (beats per minute). Create a new Age at Baseline variable. Format the Birthdate variable as mmddyy10. and the BaselineDt variable as DATE9. Perform a Proc Contents of the new data set. Perform a Proc Print of the new data set.

Summer Difficult, dirty data…SAS doesn’t like it and neither do we

Summer Part II of Lecture 2 The DATA Step Proc Freq Proc Means Which variables from the clinical2 data set would you use in each for each of these Procs?

Summer PROC FREQ Shows the distribution of categorical data values PROC FREQ Data=datasetname; TABLES variable-combinations / option(s); RUN; One-way freq tables: TABLES YearsEducation; Cross-tabulation: TABLES Sex*YearsEducation;

Summer PROC MEANS Produces simple statistics such as the mean value, standard deviation, and minimum and maximum values PROC Means Data=datasetname; Var variablenames; RUN;

Summer Lets Perform these… Create a Proc Freq on the clinical2 data set. Choose the appropriate variables. Create a Proc Means on the clinical2 data set. Choose the appropriate variables.

Summer Part III of Lecture 2 Libname Quiz!

Summer Lets try to do HW 1 together… We will use the samples of TPA data to produce descriptive statistics and graphics in order to reproduce some of the stats in Tables 1 and 2 of the TPA paper. Readings: Readings for clarification of Libname etc. for start of classes: Cody Chapters 12-14