I OWA S TATE U NIVERSITY Department of Animal Science Getting Started Using SAS Software Animal Science 500 Lecture No. 2.

Slides:



Advertisements
Similar presentations
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
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.
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Lecture 2 Introduction to C Programming
Introduction to C Programming
Introduction to C Programming
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.
I OWA S TATE U NIVERSITY Department of Animal Science Working with Your Data (Chapter 2 in the Little SAS Book) Animal Science 500 Lecture No. 4 September.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Data types and variables
Modules, Hierarchy Charts, and Documentation
Chapter 2 Data Types, Declarations, and Displays
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Introduction to C Programming
Concepts of Database Management Sixth Edition
4 Operations On Data Foundations of Computer Science ã Cengage Learning.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
I OWA S TATE U NIVERSITY Department of Animal Science Writing Flexible Codes with the SAS Macro Facility (Chapter in the 7 Little SAS Book) Animal Science.
Mr Shum Spreadsheets eBooklet. Key Words Key Word CellAn individual box on a spreadsheet RowCells going across in an horizontal line. All rows have a.
COMPUTER SCIENCE I C++ INTRODUCTION
Objectives You should be able to describe: Data Types
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Concepts of Database Management Seventh Edition
Introduction to Python
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
Numeric Processing Chapter 6, Exploring the Digital Domain.
Multiple Uses for a Simple SQL Procedure Rebecca Larsen University of South Florida.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
I OWA S TATE U NIVERSITY Department of Animal Science Getting Your Data Into SAS (Chapter 2 in the Little SAS Book) Animal Science 500 Lecture No. 3 September.
Concepts of Database Management Seventh Edition
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Introduction to Programming with RAPTOR
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
ITGS Databases.
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.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Summer SAS Workshop Lecture 3. Summer SAS Workshop Website
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
(Winter 2016) Instructor: Craig Duckett Lecture 13: Thursday, February 18 th Mere Mortals: Chap. 9 Summary, Team Work 1.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
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.
C++ for Engineers and Scientists Second Edition
10 Chapter 101 Using Menus and Validating Input Programming Logic and Design, Second Edition, Comprehensive 10.
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.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Topics Designing a Program Input, Processing, and Output
Chapter 2 Introduction to C++ Programming
Revision Lecture
Variables, Expressions, and IO
Designing and Debugging Batch and Interactive COBOL Programs
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Spreadsheets, Modelling & Databases
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Using C++ Arithmetic Operators and Control Structures
Presentation transcript:

I OWA S TATE U NIVERSITY Department of Animal Science Getting Started Using SAS Software Animal Science 500 Lecture No. 2

I OWA S TATE U NIVERSITY Department of Animal Science SAS History u Developed in the late 1960s and 1970s at North Carolina State University n Original use was for management and analysis of agricultural field experiments u Headquarters still in Cary, NC u Claim to be the most widely used statistical software u SAS used to be an acronym for “Statistical Analysis System n No real meaning today – just “SAS”

I OWA S TATE U NIVERSITY Department of Animal Science SAS Products u Base SAS – data management and basic procedures u SAS/STAT – statistical analysis u SAS/GRAPH – presentation quality graphics u SAS/OR – operations research u SAS/ETS – econometrics and time series analysis u SAS/IML – interactive matrix language u SAS/AF – applications facility (menus and interfaces) u SAS/QC – quality control u SAS/Genetics – use for analyzing genetic marker data u Other products for spreadsheets, databases, and connectivity between different machine interfaces that are running SAS

I OWA S TATE U NIVERSITY Department of Animal Science Resources for SAS u Numerous books n Published by SAS and frequently authored users themselves n Published independent of SAS n All can be purchased from a variety of on-line book stores l Amazon l ABE.com l Etc. u SAS documentation is available on-line

I OWA S TATE U NIVERSITY Department of Animal Science Resources for SAS u SAS documentation is available on-line n Majority of book or “hard” documentation can by found on-line n Extensive help section for SAS u Can SAS software consultants with technical questions that appear to not have solutions available.

I OWA S TATE U NIVERSITY Department of Animal Science On-line support u page.jsp

I OWA S TATE U NIVERSITY Department of Animal Science Format of SAS program u SAS is very user friendly n No rules about format of your program and several programming rules are allowed; l Statements or program can be written in UPPERCASE or lowercase or a COMbinATion l Statements can continue across multiple lines l Two statements can be on the same line l You can start the program or statements in any column

I OWA S TATE U NIVERSITY Department of Animal Science Making your SAS program User Friendly u Keep your program organized n Often it is easier to review your program by writing only one statement per line. n Start DATA and PROC statements in leading columns l Indent other code that follows the DATA or PROC step n To keep your code understandable, include comments l Future use l Someone else has to use or manipulate your data or program

I OWA S TATE U NIVERSITY Department of Animal Science Making your SAS program User Friendly n To keep your code understandable, include comments l Future use l Someone else has to use or manipulate your data or program l To insert comments use *ahead of comment and SAS will not read this line. Often start comment lines with multiple **** so comments are easily identifiable. l Can also “comment out” lines of sas code Surround the sas code you do not want to use but want to save using /* at the beginning and */ at the end of the code you wish to not utilize.

I OWA S TATE U NIVERSITY Department of Animal Science Making your SAS program User Friendly u To keep your code understandable, include comments l SAS can ignore the comments by surrounding it l Two ways to insert the comments 1. Start comment with * and end with a ; 2. Start with /* and end with */ 1.Use care when using this method if using program with another program or in another u Commonly called commenting or “commenting out” lines of code

I OWA S TATE U NIVERSITY Department of Animal Science Making your SAS program User Friendly u Particularly important when: n Writing materials and methods for a variety of publications n In the review process of journal articles n Keep meticulous records on your analyses

I OWA S TATE U NIVERSITY Department of Animal Science Programming Tips u Programming in SAS is a step by step process n Write a portion of the program n Begin with writing the program in small steps l The infile statement l Obtain means l Examine the distribution l Etc. n Sort out any errors – if any and correct them and move the next step of the process l Just because your program “works” or does not give you an error message does not mean everything is correct Check results or output at this point n The step by step process helps to find and correct errors more easily than attempting to write the entire program and begin the analysis at that point.

I OWA S TATE U NIVERSITY Department of Animal Science Getting Started with A SAS Analysis u Your data set must be imported u Once imported your data set is a “SAS data set” u SAS can read almost any type of data u Once your data is read, SAS will keep track of what is where and in what form it is in u User only has to provide the name and location of the data set you want to us n SAS can figure our what is in it

I OWA S TATE U NIVERSITY Department of Animal Science Data u Data you want analyzed is in a table format n Columns represent the variables of what was measured n The rows represent the observations u Data types n SAS simplifies data into 2 types 1. Numeric 2. Character

I OWA S TATE U NIVERSITY Department of Animal Science Data Data types Numeric – are numbers Can have mathematic processes carried out (added, subtracted, multiplied, divided, etc.) Can have any number of decimal places Can be positive or negative (the data sign + or – can be included in the numeric data variable column. The E can be used for scientific notation)

I OWA S TATE U NIVERSITY Department of Animal Science Data Data types Character Anything that is not a numeric data is character Data can contain numbers, letters, special characters ($,#, !, etc. If data has letters or special characters data must be character If data contains only numbers then data can be either numeric or character Sometimes data that is only numbers still may be better as a character variable Example – zip codes

I OWA S TATE U NIVERSITY Department of Animal Science Missing data u Missing data n Character missing data is depicted in a data set as a blank n Numeric missing data is noted in a data set by a.

I OWA S TATE U NIVERSITY Department of Animal Science Data characteristics u Data set size n Prior to SAS 9.1 data sets could contain 32,767 variables (columns) n SAS 9.1 and later, the number of variables not limited by software l Hardware my limit size of data set capable of being evaluated n The number of observations (rows) in all versions of SAS is not limited l Limited only by computer hardware limitations l Spreadsheet used to record data observations may be a limiting factor

I OWA S TATE U NIVERSITY Department of Animal Science SAS Naming rules u Variable names limited to 32 characters or less n Limited to the use of letters, the underscore _ key and digits and can be in either upper or lower case n SAS does remember the case of the first occurrence of each variable name and uses that case when printing results. n Before SAS version 7 the limit was 8 n Advice to use as few as possible so long as you can clearly identify the variable at some later point l Long names have to be included in any Procedure (PROC) where the variable must be identified or used in some modeling process

I OWA S TATE U NIVERSITY Department of Animal Science SAS Naming Rules u Variable names may not contain embedded blanks. n V1 and V_1 are acceptable; V 1 is not. n Graduation Date is acceptable Graduation Date is not. u Certain names are reserved for use by SAS – n _N_ n _TYPE_ n _NAME_ u Logical operators such as ge, lt, and, and eq should not be used as variable names.

I OWA S TATE U NIVERSITY Department of Animal Science SAS Program Structure u Program might also be referred to as code by some u Two components to SAS programs 1. Data step 2. Procedure step (often called the Proc step) u Every SAS statement MUST end with a semicolon ( ; ).

I OWA S TATE U NIVERSITY Department of Animal Science SAS Program Structure u The Data step n Reads data from external source – can be read into your program a variety of ways n Manipulate your data – often making new calculations based on the original data n Combines data with other data – combining data sets to do even more calculations or manipulations for a desired outcome n Print reports based on the data that is inputted – can be used for a variety of purposes n These tools can be used to prepare the data for use by one of the procedures available in SAS

I OWA S TATE U NIVERSITY Department of Animal Science SAS Program Structure u The Procedure step n Performs analyses on your data l Proc Sort l Proc Means l Proc Merge l Proc Anova l Proc Mixed n Can produce volumes of output n Often the most effective way to learn SAS (using both the data step and the procedure step) is by doing

I OWA S TATE U NIVERSITY Department of Animal Science SAS Program Structure u Statements used are exclusive to either the DATA or the PROC steps u Remember n Data steps read and modify the data n Proc steps analyze, perform a utility or print the data u Data steps must begin with the words Data n This step can also include: l DO loops l IF – THEN /ELSE logic l SELECT – WHEN / ELSE l Large assortment of other numeric and / or character function

I OWA S TATE U NIVERSITY Department of Animal Science SAS Program Structure u Data steps must begin with the words Data n Can combine data in a variety of ways l Match and merge – i.e. merging by id for example l Concatenate – merging two variables end to end

I OWA S TATE U NIVERSITY Department of Animal Science SAS Program Structure u Procedure statements must begin with PROC followed by a name of a procedure n Print n Sort n Means u A step ends when SAS finds: 1. A new step (the next DATA or PROC statement) 2. A run statement 3. The end of the program (if running in batch mode)

I OWA S TATE U NIVERSITY Department of Animal Science SAS Program Structure u The run statement tells SAS to run all of the preceding lines of a step n Can also indicate to run the lines that are highlighted u Is also the rare “global” statements that are not part of a DATA or PROC step u I typically place a “quit” statement (quit;) after each run statement n Prevents your program from remaining in a do loop or continue running when the program has an error and continues to run potentially infinitely.

I OWA S TATE U NIVERSITY Department of Animal Science Arithmetic Operators u Arithmetic operators indicate that an arithmetic calculation is performed, as shown in the following table:

I OWA S TATE U NIVERSITY Department of Animal Science Arithmetic Operators OperationSymbolExampleResult +addition Num + Num Example: add two numbers together -subtraction Num - Num Example: 5 – 3 or can use two variables ending wt. – beginning wt. subtract the value of * multiplication (table note 1)(table note 1) 2*y Always have to have * cannot use 2(y) or 2y multiply 2 by the value of Y /division var/5 or can use variable weight gain / days on test divide the value of VAR by 5 ** can also use the ^ exponentiation a**2 or a^2 raise A to the second power