Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to SAS®.

Similar presentations


Presentation on theme: "Introduction to SAS®."— Presentation transcript:

1 Introduction to SAS®

2 Objectives List the components of a SAS program.
Open an existing SAS program and run it.

3 SAS Programs A SAS program is a sequence of steps that the user submits for execution. Raw Data DATA steps are typically used to create SAS data sets. SAS Data Set DATA Step PROC Step Report SAS Data Set PROC steps are typically used to process SAS data sets (that is, generate reports and graphs, edit data, and sort data).

4 SAS Programs DATA Step PROC Steps DATA one;
INPUT Name $ Gender $ Runtime Age Weight ; DATALINES; Donna F Gracie F Luanne F Mimi F Chris M ; RUN; PROC PRINT DATA=one; PROC REG DATA=one; MODEL Runtime=Weight; DATA Step PROC Steps

5 SAS Windowing Environment
Interactive windows enable you to interface with SAS.

6 Exercises Open the SAS program “example.sas.”
Submit the program and examine the results. Files for today's class located at

7 Objectives Learn the two fundamental SAS syntax programming rules.
Create a SAS dataset from a space delimited inline text file. Create a SAS dataset from a comma delimited inline text file. Create a SAS dataset from a comma delimited external text file. Reading an Excel file PROC IMPORT via Import Wizard

8 Fundamental SAS Syntax Rules
SAS statements have these characteristics: usually begin with an identifying keyword always end with a semicolon data staff; input LastName $ FirstName $ JobTitle $ Salary; datalines; …insert text data here… run; proc print data=staff;

9 Example of a typical space delimited text file ‘space.txt’
Name Gender Runtime Age Weight Donna F Gracie F Luanne F Mimi F Chris M

10 Creating a SAS data set from a space delimited text file: The Data Step
DATA one; INPUT Name $ Gender $ Runtime Age Weight; DATALINES; Donna F Gracie F Luanne F Mimi F Chris M ; RUN; PROC PRINT DATA=one;

11 Example of a typical comma delimited text data set. ‘Comma.txt’
Name,Gender,Runtime,Age,Weight Donna,F,8.17,42,68.15 Gracie,F,8.63,38,81.87 Luanne,F,8.65,43,85.84 Mimi,F,8.92,50,70.87 Chris,M,8.95,49,81.42

12 Creating a SAS data set from a comma delimited text file: The Data Step
DATA two; INFILE DATALINES DLM=',' DSD MISSOVER; INPUT Name $ Gender $ Runtime Age Weight; DATALINES; Donna,F,8.17,42,68.15 Gracie,F,8.63,38,81.87 Luanne,F,8.65,,85.84 Mimi,F,8.92,50 Chris,M,8.95,49,81.42 ; RUN; PROC PRINT DATA=two;

13 INFILE Options Option Description DLM=
INFILE "raw-data-file" <DLM=> <DSD> <MISSOVER>; Option Description DLM= Specifies an alternate delimiter. DSD Sets the default delimiter to a comma, treats consecutive delimiters as missing values, and allows embedded delimiters when the data value is enclosed in quotation marks. MISSOVER Sets variables to missing if the end of the record is reached before finding values for all fields.

14 Creating a SAS data set from an external comma delimited text file: The Data Step
DATA three; INFILE 'C:\USERS\BACONR\DESKTOP\comma.txt' DLM=',' DSD MISSOVER FIRSTOBS=2; INPUT Name $ Gender $ Runtime Age Weight; RUN; PROC PRINT DATA=three;

15 Example of a typical comma delimited text data set. ‘Comma.txt’
Name,Gender,Runtime,Age,Weight Donna,F,8.17,42,68.15 Gracie,F,8.63,38,81.87 Luanne,F,8.65,43,85.84 Mimi,F,8.92,50,70.87 Chris,M,8.95,49,81.42

16 Reading an Excel File Typical Excel file: ‘myexcel.xlsx’

17 Creating a SAS data set from an EXCEL file:
PROC IMPORT via the SAS IMPORT WIZARD 32-bit SAS 64-bit SAS

18 Capturing the Syntax: PROC IMPORT via the SAS IMPORT WIZARD

19 Creating a SAS data set from an EXCEL FILE: PROC IMPORT via the IMPORT WIZARD
32-bit PROC IMPORT OUT= WORK.four DATAFILE= "C:\Users\baconr\Downloads\myexcel.xlsx" DBMS=EXCEL REPLACE; RANGE="comma$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; PROC PRINT DATA=four;


Download ppt "Introduction to SAS®."

Similar presentations


Ads by Google