Professional Seminar Northwestern Polytechnic University By Dr. Michael M Cheng.

Slides:



Advertisements
Similar presentations
Copyright © 2006, SAS Institute Inc. All rights reserved. Think FAST! Use Memory Tables (Hashing) for Faster Merging Gregg P. Snell Data Savant Consulting.
Advertisements

I OWA S TATE U NIVERSITY Department of Animal Science Using Basic Graphical and Statistical Procedures (Chapter in the 8 Little SAS Book) Animal Science.
Describing Quantitative Variables
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Slide C.1 SAS MathematicalMarketing Appendix C: SAS Software Uses of SAS  CRM  datamining  data warehousing  linear programming  forecasting  econometrics.
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
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.
Introduction to SQL Session 2 Retrieving Data From Multiple Tables.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
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.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
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.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Access 2010 © 2011 The McGraw-Hill Companies,
Shell Scripting Awk (part1) Awk Programming Language standard unix language that is geared for text processing and creating formatted reports but it.
SAS SQL SAS Seminar Series
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.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
SAS SQL Part 2 Alan Elliott. Dealing with Missing Values Title "Dealing with Missing Values in SQL"; PROC SQL; select INC_KEY,GENDER, RACE, INJTYPE, case.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
Learning to love the SAS LAG function Phuse 9-12 October 2011 Herman Ament, MSD, Oss NL Phuse 9-12 October 2011.
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 Macro: Some Tips for Debugging Stat St. Paul’s Hospital April 2, 2007.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
TRANSFORMING SAS DATA SETS Creating new SAS data sets with the SET statement – how the DATA step works Creating and transforming variables – assignment.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
SQL Chapter Two. Overview Basic Structure Verifying Statements Specifying Columns Specifying Rows.
Chapter 3 “Working With Your Data” concerns programming in the DATA step - putting lines of SAS code between a DATA and PROC statement… Creating new variables.
1 Tutorial 2 GE 5 Tutorial 2  rules of engagement no computer or no power → no lesson no computer or no power → no lesson no SPSS → no lesson no SPSS.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
In this session, you will learn to: Use functions to customize the result set Summarize and group data Objectives.
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.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
Lesson 4 - Topics Creating new variables in the data step SAS Functions.
The Power of the BY Statement SVSUG Paul Choate, California Developmental Services (& Toby Dunn, U.S. Army Medical Department Center & School)
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
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.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
Pascal Programming Making decisions - Selection Statements National Certificate Unit 4 Carl Smith.
“LAG with a WHERE” and other DATA Step Stories Neil Howard A.
Shell script – part 2 CS 302. Special shell variable $0.. $9  Positional parameters or command line arguments  For example, a script myscript take 2.
Chapter 17 Supplement: Alternatives to IF-THEN/ELSE Processing STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South.
TASS Meeting Using Multiple DOW Loops September 25th, 2009 Using Multiple DOW Loops Dr. Arthur Tabachneck Director, Data Management Idea stolen from a.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
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.
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
Lecture 9 Using Structured Query Language (SQL) Jeffery S. Horsburgh Hydroinformatics Fall 2012 This work was funded by National Science Foundation Grant.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 8, 13, & 24 By Tasha Chapman, Oregon Health Authority.
1 Ready To Become Really Productive Using PROC SQL? Sunil Gupta Gupta Programming.
Notes on SQL. SQL Programming Employers increasingly tell us that they look for 3 things on a resume: SAS, R and SQL. In these notes you will learn: 1.What.
Applied Business Forecasting and Regression Analysis
Control Structures: if Conditional
SAS Essentials How SAS Thinks
Subsetting Rows with the WHERE clause
Introduction to DATA Step Programming SAS Basics II
Introduction to DATA Step Programming: SAS Basics II
Producing Descriptive Statistics
Query Functions.
DATA TYPES AND OPERATIONS
Presentation transcript:

Professional Seminar Northwestern Polytechnic University By Dr. Michael M Cheng

Quiz Select the following multiple choices. What is SAS? a.SAS is a highly contagious disease found in the winter time in Asia. b. SAS is sardines and salmon. c. SAS is a software that compute statistics only. d. SAS is a 4 th generation computer language capable of performing full feature computer programming. e. None of the above.

SAS (SAS System) A computer software system that consists of several products that provide data retrieval, management, and analysis capabilities in addition to programming (SAS Institute, Inc.) SAS is a problem solving tool.

Heuristic Problem Solving Image Mode 1 Linguistic Mode 1 Image Mode 2 Linguistic Mode 2 The interaction between image mode and linguistic mode is called Heuristic Problem Solving.

Psychology of Communication By George Miller Coding Decoding Channel Capacity Magic number 7 plus or minus 2 For example:

Psychology of Communication By George Miller Coding Decoding Channel Capacity Magic number 7 plus or minus 2 For example: ??????????

Psychology of Communication By George Miller Coding Decoding Channel Capacity Magic number 7 plus or minus 2 For example:

SAS program source code is composed of many SAS statements, and some for PROC step, some for DATA step, and some used in either step.

SAS Syntax and SAS Data Sets SAS statements begin with an identifying keyword and end with a semicolon; SAS statements are free-format. A SAS data set is a collection of data values arranged in a rectangular tables. The columns in the table are called variables. The rows in the table are called observations (or records). There are two kinds of variables: character variables number variables

VARIABLES NAME SEX AGE HEIGHT WEIGHT observations 1 JOHN M observations 2 JAMES M observations 3 AFLRED M observations 19 ALICE F

DATA CLASS; INPUT NAME $1-8 SEX $11 AGE HEIGHT WEIGHT 21-25; CARDS; data lines PROC PRINT DATA=CLASS; PROC MEANS DATA=CLASS; VARIABLES HEIGHT WEIGHT;

Raw data DATA CLASS; INPUT NAME $1-8 SEX $11 AGE HEIGHT WEIGHT 21-25; CARDS; CLASS Creating SAS data sets

A listing of the raw data NAME SEX AGE HEIGHT WEIGHT JOHN M JAMES M ALFRED M WILLIAM M JEFFREY M RONALD M THOMAS M PHILIP M ROBERT M HENRY M JANET F JOYCE F JUDY F CAROL F JANE F LOUISE F BARBARA F MARY F ALICE F

CARDS; /* data lines */ JOHN M JAMES M ALFRED M WILLIAM M JEFFREY M RONALD M THOMAS M PHILIP M ALFRED M ROBERT M HENRY M JANET F JOYCE F JUDY F CAROL F JANE F LOUISE F BARBARA F MARY F ALICE F

PROC PRINT DATA=CLASS; SAS OBS NAME SEX AGE HEIGHT WEIGHT 1 JOHN M JAMES M ALFRED M WILLIAM M JEFFREY M RONALD M THOMAS M PHILIP M ALFRED M HENRY M JANET F JOYCE F JUDY F CAROL F JANE F LOUISE F BARBARA F MARY F ALICE F

PROC MEANS DATA=CLASS; VARIABLES HEIGHT WEIGHT; SAS VARIABLES N MEAN STANDARD MINIMUM MAXIMUM STD ERROR DEVIATION VALUE VALUE OF MEAN WEIGHT HEIGHT

THE PROC STEP  The PROC (or PROCEDURE) statement is used to call a SAS procedure.  SAS procedures are computer programs that: read SAS data sets, compute statistics, print results, and create SAS data sets. For example: PROC MEANS SUM MAXDEC=2 DATA=CLASS; PROC CONTENTS DATA=CLASS; PROC SORT DATA=CLASS; BY SEX DESCENDING WEIGHT;

Data Transformations Assignment statement Assignment statements are used to create new variable and to modify values of existing variables. SAS evaluates an expression and assigns the result to a variable. variable = expression; i.e. x=1+2;

Example: 1. Read three variables (YEAR, REVENUE, and EXPENSE) into a SAS data set. 2. Add a variable named INCOME, which is the difference between REVENUE and EXPENSE. 3. Change the values of YEAR from 2 digits to 4 digits. DATA PROFITS; INPUT YEAR REVENUE EXPENSE; INCOME=REVENUE–EXPENSE; YEAR = YEAR ; CARDS; PROC PRINT: SAS OBS YEAR REVENUE EXPENSE INCOME

SAS functions Selected functions that compute simple statistics. SUM sum MEAN arithmetic mean VAR variance MIN minimum value MAX maximum value STD standard deviation

Example: Given: Temperature data at a specific location are recorded every hour on the hour for several days. Each record in a file represents one day and contains the date and the 24 recorded temperatures for that date. Objective: Create a SAS data set that contains the date, the 24 hourly temperatures, the average temperature, the minimum temperature and the maximum temperature for each day. DATA TEMP; INPUT DATE (T1-T24) (2.); AVGTEMP=MEAN(OF T1-T24); MINTEMP=MIN(OF T1-T24); MAXTEMP=MAX(OF T1-T24); CARDS; data lines program data vector DATE T1... AVGTEMP MINTEMP MAXTEMP

The RETAIN statement SAS normally resets all variables in the program data vector to missing before each execution of the DATA step. A RETAIN statement can be used to: - Retain variable values from the last execution of the DATA step - Give initial values to the valuables. Example: Accumulate totals and count observations. DATA ADD; RETAIN COUNT 0 TOTAL 0; INPUT SCORE; TOTALS=TOTAL+SCORE; CARDS; PROC PRINT; program data vector COUNT TOTAL SCORE

The SUM statement The SUM statement is a special assignment statement that accumulates values from one observation to the next. It retains the values of the created variable and treats a missing value as zero. Example: Accumulate totals and count observations. DATA ADD; INPUT SCORE; COUNT + 1; TOTALS=TOTAL+SCORE; CARDS; PROC PRINT;

CONDITIONAL EXECUTION OF SAS STATEMENT IF-THEN/ELSE Statements Use of the IF-THEN statement when you want to execute a SAS Statement conditional on some expression. Numeric Comparison IF CODE=1 THEN RESPONSE=‘GOOD’; IF CODE=2 THEN RESPONSE=FAIR’; IF CODE=3 THEN RESPONSE=‘POOR; For efficiency, use ELSE statements. IF CODE=1 THEN RESPONSE=“GOOD’; ELSE IF CODE=2 THEN RESPONSE=‘FAIR’ ELSE IF CODE=3 THEN RESPONSE=‘POOR”;

Character comparison DATA CLASS; INPUT NAME $SEX $AGE HEIGHT WEIGHT; IF SEX=‘M’ THEN SEX=‘MALE’; ELSE SEX=‘FEMALE’; CARDS;

Comparison operators LT < less than GT < greater than EQ = equal than LE <= less than or equal to GE >= greater than or equal to NE not equal NL not less than NG not greater than Logical operators OR l or, either AND & and NOT not, negation

DO and END statements Execution of a DO statement specifies that all statements between the DO and its matching END statement are to be executed. For example: DATA EMPLOY; INPUT NAME $1-8 DEPNO COM SALARY 19-23; IF DEPTNO=201 THEN DO; DEPT=‘SALES’; GROSSPAY = COM+SALARY; END; ELSE DO; DEPT=‘ADMIN’; GROSSPAY = SALARY; END; CARDS;

JOHNSON MOSSER LARKIN GARRETT PROC PRINT output SAS OBS NAME DEPTNO COM SARLARY DEPT GROSSPAY 1 JOHNSON SALES MOSSER ADMIN LARKIN ADMIN GARRETT SALES 22800

PROC SORT DATA=RATE_A; BY ZIP; PROC SORT DATA=RATE_B; BY ZIP; PROC SORT DATA=RATE_C; BY ZIP; DATA TMTL; MERGE RATE_A(IN=A) CTL_TBL(IN=B); BY ZIP; IF A & B; DATA TMMR; MERGE RATE_B(IN=A) CTL_TBL(IN=B); BY ZIP; IF A & B; DATA TMCR; MERGE RATE_C(IN=A) CTL_TBL(IN=B); BY ZIP; IF A & B;

Conclusion 1.SAS is a 4th generation computer language. 2.SAS is a problem solving tool. 3.It makes your life easier (less stressful).

THE END