Docsity

SAS Programming: Understanding the Language, Data Sets, Output, and System Options - Prof., Study notes of Database Programming

Partial preview of the text

Download SAS Programming: Understanding the Language, Data Sets, Output, and System Options - Prof. and more Study notes Database Programming in PDF only on Docsity!

SAS Basic Concepts

The language, log, output, SAS data set and others

JC Wang

Department of Statistics Western Michigan University

September 8, 2009

Outline

(^1) The Language

Language Elements SAS Log SAS Libraries

(^2) SAS Data Sets

Two Portions of a SAS Data Set

(^3) SAS Output

SAS Output: An Example

(^4) System Options

(^5) SAS Comments

(^6) Report Writing—Round One

Language Elements

Consists of statements

Statements usually start with keywords

Each statement ends with a semicolon (;)

Words in statements are case insensitive, except for most situations when texts are enclosed in matching quotation marks, single quotes (’) or double quotes (")

Language Elements

Consists of statements

Statements usually start with keywords

Each statement ends with a semicolon (;)

Words in statements are case insensitive, except for most situations when texts are enclosed in matching quotation marks, single quotes (’) or double quotes (")

Language Elements

Consists of statements

Statements usually start with keywords

Each statement ends with a semicolon (;)

Words in statements are case insensitive, except for most situations when texts are enclosed in matching quotation marks, single quotes (’) or double quotes (")

Program Layout

SAS statements are in free format,

they can begin/end anywhere on a line a statement can continue over several lines several statements can be on a line (avoid this)

Program Layout

SAS statements are in free format,

they can begin/end anywhere on a line a statement can continue over several lines several statements can be on a line (avoid this)

Program Layout

SAS statements are in free format,

they can begin/end anywhere on a line a statement can continue over several lines several statements can be on a line (avoid this)

Basic Building Blocks of a SAS Program

There are two basic building blocks:

Data steps: read raw data, create/modify data, set/change data value, combine/merge/update data sets Proc steps: pre-written procedures that perform various tasks

Note: In addition to above, there are stand-alone statements such as OPTIONS, TITLE, FOOTNOTE, LIBNAME, FILENAME, ...

Basic Building Blocks of a SAS Program

There are two basic building blocks:

Data steps: read raw data, create/modify data, set/change data value, combine/merge/update data sets Proc steps: pre-written procedures that perform various tasks

Note: In addition to above, there are stand-alone statements such as OPTIONS, TITLE, FOOTNOTE, LIBNAME, FILENAME, ...

Step Boundaries

DATA & PROC statements signal the beginning of a new step

Subsequent DATA or PROC statements, RUN statements (for DATA steps and most PROC steps) or a QUIT statement(for interactive PROC steps such as PROC DATASETS, PROC GLM, PROC REG, PROC SQL, PROC IML) signal the end of a step

Upon encountering new step, SAS stops reading statements and executes the previous step

Step Boundaries

DATA & PROC statements signal the beginning of a new step

Subsequent DATA or PROC statements, RUN statements (for DATA steps and most PROC steps) or a QUIT statement(for interactive PROC steps such as PROC DATASETS, PROC GLM, PROC REG, PROC SQL, PROC IML) signal the end of a step

Upon encountering new step, SAS stops reading statements and executes the previous step

Step Boundaries

DATA & PROC statements signal the beginning of a new step

Subsequent DATA or PROC statements, RUN statements (for DATA steps and most PROC steps) or a QUIT statement(for interactive PROC steps such as PROC DATASETS, PROC GLM, PROC REG, PROC SQL, PROC IML) signal the end of a step

Upon encountering new step, SAS stops reading statements and executes the previous step

SAS Log

upon submitting a program, SAS generates a log of processing activities

SAS Log Example

See eg01.sas