notes2 - What Is SAS? SAS is a collection of components...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: What Is SAS? SAS is a collection of components that enable you to manage, manipulate, and examine your data. Reporting Reporting and and Graphics Graphics Analytical Analytical Data Access Data Access and and Management Management Base SAS Base SAS User User Interfaces Interfaces Application Application Development Development Notes 2: SAS Basics Visualization Visualization and Discovery and Discovery Business Business Solutions Solutions Web Web Enablement Enablement 1 2 Basic Functionality Access Manage Running a SAS Program You can invoke SAS in interactive windowing mode (SAS windowing environment) interactive menu-driven mode (SAS Enterprise Guide, SAS/ASSIST, SAS/AF, or SAS/EIS software) batch mode Data Present Analyze noninteractive mode. 3 4 SAS Windowing Environment Interactive windows enable you to interface with SAS. Submitting a SAS Program When you execute a SAS program, the output generated by SAS is divided into two major parts: SAS log contains information about the processing of the SAS program, including any warning and error messages. SAS output contains reports generated by SAS procedures and DATA steps. 5 6 1 1 data work.staff; raw-data2 infile 'raw-data-file'; 1213 input LastName $ 1-20 FirstName $ 21-30 36544 JobTitle $ 36-43 Salary 54-59; 5 run; raw-dataNOTE: The infile 'raw-data-file' is: raw-dataFile Name= 'raw-data-file', RECFM=V,LRECL=256 raw-dataNOTE: 18 records were read from the infile 'raw-data-file'. The minimum record length was 59. The maximum record length was 59. variables. NOTE: The data set WORK.STAFF has 18 observations and 4 variables. 6 proc print data=work.staff; 7 run; WORK.STAFF. NOTE: There were 18 observations read from the dataset WORK.STAFF. 8 proc means data=work.staff; 9 class JobTitle; 10 var Salary; 11 run; WORK.STAFF. NOTE: There were 18 observations read from the dataset WORK.STAFF. SAS Log PROC PRINT Output The SAS System Obs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 LastName TORRES LANGKAMM SMITH LEISTNER WADE TOMAS WAUGH LEHMANN TRETTHAHN TIETZ O'DONOGHUE WALKER NOROVIITA OESTERBERG LAUFFER TORR WAGSCHAL TOERMOEN First Name JAN SARAH MICHAEL COLIN KIRSTEN HARALD TIM DAGMAR MICHAEL OTTO ART THOMAS JOACHIM ANJA CRAIG JUGDISH NADJA JOCHEN JobTitle Pilot Mechanic Mechanic Mechanic Pilot Pilot Pilot Mechanic Pilot Pilot Mechanic Pilot Mechanic Mechanic Mechanic Pilot Pilot Pilot Salary 50000 80000 40000 36000 85000 105000 70000 64000 100000 45000 52000 95000 78000 80000 40000 45000 77500 65000 8 7 PROC MEANS Output The SAS System The MEANS Procedure Analysis Variable : Salary N JobTitle Obs N Mean Std Dev Minimum Mechanic 8 8 58750.00 19151.65 36000.00 Pilot 10 10 73750.00 22523.14 45000.00 Analysis Variable : Salary N JobTitle Obs Maximum Mechanic 8 80000.00 Pilot 10 105000.00 9 10 Lab 1: Exercise 1 Exploring your SAS Environment under Windows Types of Files Used with SAS Turning Data into Information Raw Data DATA Step Raw Data Files SAS DATA Sets SAS Program Files SAS Data Sets PROC Steps Information 11 12 2 Raw Data Files Raw Data Files SAS Data Sets SAS Data Sets are nonsoftware-specific files that contain records and fields can be created by a variety of software products can be read by a variety of software products consist of no special attributes, such as field headings, page breaks, or titles are not reports. 13 are files specific to SAS that contain variables and observations can be created only by SAS can be read only by SAS consist of a descriptor portion and a data portion 14 SAS Program Files SAS Program Files Components of a SAS Program A SAS program is a sequence of steps. There are only two kinds of steps: DATA steps PROC steps. A SAS Program DATA step(s) contain SAS program code can be saved and reused file extension is .sas PROC step(s) 15 16 SAS Programs A SAS program is a sequence of steps that the user submits for execution. DATA steps are typically used to create SAS data sets. DATA DATA Step Step SAS Data Set SAS Data Set PROC PROC Step Step Report Report DATA Step(s) Typically, DATA steps read data, such as raw data files, to create SAS data sets. Raw Data File SAS Data Set Descriptor Raw Raw Data Data DATA Step PROC steps are typically used to process SAS data sets (that is, generate reports and graphs, edit data, and sort data). 17 18 3 DATA Step(s) In addition, DATA steps can modify existing variables or create new variables as necessary. Raw Data File SAS Data Set Descriptor PROC Step(s) PROC steps typically read SAS data sets to create reports. SAS Data Set Descriptor Report DATA Step PROC Step 19 20 PROC Step(s) There are many different types of PROC steps. PROC Step(s) PRINT ... Components of a Step A SAS program is a sequence of steps: DATA steps PROC steps. A step is a sequence of one or more statements. MEANS FREQ 21 22 Components of a Step A statement usually starts with a keyword and always ends in a semicolon (;) KEYWORD ......;; KEYWORD Components of a DATA Step A DATA step starts with a DATA statement and ends with a RUN statement. Start data _______________ ; _______________ ; . . . _______________ ; End 23 run; 24 4 Components of a PROC Step A PROC step starts with a PROC statement and ends with a RUN statement. Start SAS Programs data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; run; proc means data=work.staff; class JobTitle; var Salary; run; PROC Steps DATA Step proc _______________ ; _______________ ; . . . _______________ ; End run; 25 26 Step Boundaries SAS steps begin with a DATA statement PROC statement. SAS detects the end of a step when it encounters a RUN statement (for most steps) a QUIT statement (for some procedures) the beginning of another step (DATA statement or PROC statement). 27 Step Boundaries data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; proc means data=work.staff; class JobTitle; var Salary; run; 28 SAS Syntax Rules SAS statements usually begin with an identifying keyword always end with a semicolon. data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; run; proc means data=work.staff; class JobTitle; var Salary; run; SAS Syntax Rules SAS statements are free-format. One or more blanks or special characters can be used to separate words. They can begin and end in any column. A single statement can span multiple lines. Several statements can be on the same line. Unconventional Spacing data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff; class JobTitle; var Salary;run; 29 30 5 SAS Syntax Rules SAS statements are free-format. One or more blanks or special characters can be used to separate words. They can begin and end in any column. A single statement can span multiple lines. Several statements can be on the same line. Unconventional Spacing data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff; class JobTitle; var Salary;run; SAS Syntax Rules SAS statements are free-format. One or more blanks or special characters can be used to separate words. They can begin and end in any column. A single statement can span multiple lines. Several statements can be on the same line. Unconventional Spacing data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff; class JobTitle; var Salary;run; 31 32 SAS Syntax Rules SAS statements are free-format. One or more blanks or special characters can be used to separate words. They can begin and end in any column. A single statement can span multiple lines. Several statements can be on the same line. Unconventional Spacing data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff; class JobTitle; var Salary;run; SAS Syntax Rules SAS statements are free-format. They can begin and end in any column. One or more blanks or special characters can be used to separate words. A single statement can span multiple lines. Several statements can be on the same line. Unconventional Spacing data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc means data=work.staff; class JobTitle; var Salary;run; 33 34 SAS Syntax Rules Good spacing makes the program easier to read. Conventional Spacing data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff; run; proc means data=work.staff; class JobTitle; var Salary; run; SAS Comments Type /* to begin a comment. Type your comment text. Type */ to end the comment. /* Create work.staff data set */ data work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; /* Produce listing report of work.staff */ proc print data=work.staff; run; 35 36 6 Syntax Errors Syntax errors include misspelled keywords missing or invalid punctuation invalid options. daat work.staff; infile 'raw-data-file'; input LastName $ 1-20 FirstName $ 21-30 JobTitle $ 36-43 Salary 54-59; run; proc print data=work.staff run; proc means data=work.staff average max; class JobTitle; var Salary; run; Lab 1: Exercise 2 Debugging a SAS Program 37 38 7 ...
View Full Document

This note was uploaded on 10/31/2011 for the course STAT 440 taught by Professor Muyot,m during the Fall '08 term at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online