sas basic concepts #1 - wmich.edu language sas data sets sas outputsystem optionssas commentsreport...

72
The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS data set and others JC Wang wang (WMU) Basic Concepts 1 S680, Lectures 1&2 1 / 21

Upload: dobao

Post on 09-Mar-2018

232 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

SAS Basic Concepts #1The language, log, output, SAS data set and others

JC Wang

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 1 / 21

Page 2: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Outline1 The Language

Language ElementsSAS LogSAS Libraries

2 SAS Data SetsTwo Portions of a SAS Data Set

3 SAS OutputSAS Output: An Example

4 System Options

5 SAS Comments

6 Report Writing—Round One

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 2 / 21

Page 3: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Language Elements

Consists of statementsStatements usually start with keywords (egs: DATA, PROC,INPUT, KEEP, IF, DO, ...)Each statement ends with a semicolon (;)Words in statements are case insensitive, except for mostsituations when texts are enclosed in matching quotation marks,single quotes (’) or double quotes (")

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 3 / 21

Page 4: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Language Elements

Consists of statementsStatements usually start with keywords (egs: DATA, PROC,INPUT, KEEP, IF, DO, ...)Each statement ends with a semicolon (;)Words in statements are case insensitive, except for mostsituations when texts are enclosed in matching quotation marks,single quotes (’) or double quotes (")

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 3 / 21

Page 5: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Language Elements

Consists of statementsStatements usually start with keywords (egs: DATA, PROC,INPUT, KEEP, IF, DO, ...)Each statement ends with a semicolon (;)Words in statements are case insensitive, except for mostsituations when texts are enclosed in matching quotation marks,single quotes (’) or double quotes (")

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 3 / 21

Page 6: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Language Elements

Consists of statementsStatements usually start with keywords (egs: DATA, PROC,INPUT, KEEP, IF, DO, ...)Each statement ends with a semicolon (;)Words in statements are case insensitive, except for mostsituations when texts are enclosed in matching quotation marks,single quotes (’) or double quotes (")

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 3 / 21

Page 7: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Language Elements

Consists of statementsStatements usually start with keywords (egs: DATA, PROC,INPUT, KEEP, IF, DO, ...)Each statement ends with a semicolon (;)Words in statements are case insensitive, except for mostsituations when texts are enclosed in matching quotation marks,single quotes (’) or double quotes (")

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 3 / 21

Page 8: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Program Layout

SAS statements are in free format,they can begin/end anywhere on a linea statement can continue over several linesseveral statements can be on a line (avoid this)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 4 / 21

Page 9: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Program Layout

SAS statements are in free format,they can begin/end anywhere on a linea statement can continue over several linesseveral statements can be on a line (avoid this)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 4 / 21

Page 10: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Program Layout

SAS statements are in free format,they can begin/end anywhere on a linea statement can continue over several linesseveral statements can be on a line (avoid this)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 4 / 21

Page 11: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Program Layout

SAS statements are in free format,they can begin/end anywhere on a linea statement can continue over several linesseveral statements can be on a line (avoid this)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 4 / 21

Page 12: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Basic Building Blocks of a SAS Program

There are two basic building blocks:Data steps: read raw data, create/modify data, set/change datavalue, combine/merge/update data setsProc steps: pre-written procedures that perform various tasks

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

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 5 / 21

Page 13: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Basic Building Blocks of a SAS Program

There are two basic building blocks:Data steps: read raw data, create/modify data, set/change datavalue, combine/merge/update data setsProc steps: pre-written procedures that perform various tasks

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

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 5 / 21

Page 14: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Basic Building Blocks of a SAS Program

There are two basic building blocks:Data steps: read raw data, create/modify data, set/change datavalue, combine/merge/update data setsProc steps: pre-written procedures that perform various tasks

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

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 5 / 21

Page 15: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Basic Building Blocks of a SAS Program

There are two basic building blocks:Data steps: read raw data, create/modify data, set/change datavalue, combine/merge/update data setsProc steps: pre-written procedures that perform various tasks

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

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 5 / 21

Page 16: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Step Boundaries

DATA & PROC statements signal the beginning of a new stepSubsequent DATA or PROC statements, RUN statements (forDATA steps and most PROC steps) or a QUIT statement (forinteractive PROC steps such as PROC DATASETS, PROC GLM,PROC REG, PROC SQL, PROC IML) signal the end of a stepUpon encountering new step, SAS stops reading statements andexecutes the previous step

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 6 / 21

Page 17: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Step Boundaries

DATA & PROC statements signal the beginning of a new stepSubsequent DATA or PROC statements, RUN statements (forDATA steps and most PROC steps) or a QUIT statement (forinteractive PROC steps such as PROC DATASETS, PROC GLM,PROC REG, PROC SQL, PROC IML) signal the end of a stepUpon encountering new step, SAS stops reading statements andexecutes the previous step

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 6 / 21

Page 18: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Step Boundaries

DATA & PROC statements signal the beginning of a new stepSubsequent DATA or PROC statements, RUN statements (forDATA steps and most PROC steps) or a QUIT statement (forinteractive PROC steps such as PROC DATASETS, PROC GLM,PROC REG, PROC SQL, PROC IML) signal the end of a stepUpon encountering new step, SAS stops reading statements andexecutes the previous step

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 6 / 21

Page 19: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Step Boundaries

DATA & PROC statements signal the beginning of a new stepSubsequent DATA or PROC statements, RUN statements (forDATA steps and most PROC steps) or a QUIT statement (forinteractive PROC steps such as PROC DATASETS, PROC GLM,PROC REG, PROC SQL, PROC IML) signal the end of a stepUpon encountering new step, SAS stops reading statements andexecutes the previous step

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 6 / 21

Page 20: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

SAS Log

upon submitting a program, SAS generates a log of processingactivities

SAS Log ExampleSee eg01.sas (run 001.sas first, note that the SAS data path need tobe specified accordingly)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 7 / 21

Page 21: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

A SAS libraryis a collection of SAS files, including SAS data sets

Two types of librariestemporary: WORKpermanent: all others, default is SASUSER

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 8 / 21

Page 22: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

A SAS libraryis a collection of SAS files, including SAS data sets

Two types of librariestemporary: WORKpermanent: all others, default is SASUSER

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 8 / 21

Page 23: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

A SAS libraryis a collection of SAS files, including SAS data sets

Two types of librariestemporary: WORKpermanent: all others, default is SASUSER

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 8 / 21

Page 24: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Referencing a SAS data setlibref.filename

libref gives the name of library; filename gives the name of SASfileeither name consists of alphabets (lower or upper case), digits (0to 9), and underscore (_) and must not start with digitslibref can be 1 to 8 characters longfilename (a SAS name) can be 1 to 32 characters long (forversions 8 or later, 8 characters long for order version)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 9 / 21

Page 25: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Referencing a SAS data setlibref.filename

libref gives the name of library; filename gives the name of SASfileeither name consists of alphabets (lower or upper case), digits (0to 9), and underscore (_) and must not start with digitslibref can be 1 to 8 characters longfilename (a SAS name) can be 1 to 32 characters long (forversions 8 or later, 8 characters long for order version)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 9 / 21

Page 26: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Referencing a SAS data setlibref.filename

libref gives the name of library; filename gives the name of SASfileeither name consists of alphabets (lower or upper case), digits (0to 9), and underscore (_) and must not start with digitslibref can be 1 to 8 characters longfilename (a SAS name) can be 1 to 32 characters long (forversions 8 or later, 8 characters long for order version)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 9 / 21

Page 27: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Referencing a SAS data setlibref.filename

libref gives the name of library; filename gives the name of SASfileeither name consists of alphabets (lower or upper case), digits (0to 9), and underscore (_) and must not start with digitslibref can be 1 to 8 characters longfilename (a SAS name) can be 1 to 32 characters long (forversions 8 or later, 8 characters long for order version)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 9 / 21

Page 28: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Referencing a SAS data setlibref.filename

libref gives the name of library; filename gives the name of SASfileeither name consists of alphabets (lower or upper case), digits (0to 9), and underscore (_) and must not start with digitslibref can be 1 to 8 characters longfilename (a SAS name) can be 1 to 32 characters long (forversions 8 or later, 8 characters long for order version)

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 9 / 21

Page 29: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Assigning a librefan example

LIBNAME clinic ’f:\Stat 6800\sasdata’;

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 10 / 21

Page 30: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Outline1 The Language

Language ElementsSAS LogSAS Libraries

2 SAS Data SetsTwo Portions of a SAS Data Set

3 SAS OutputSAS Output: An Example

4 System Options

5 SAS Comments

6 Report Writing—Round One

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 11 / 21

Page 31: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two portions of a SAS data set

Each SAS data set has two portionsdescriptor portion: contains data set attributes (name, date/timecreated, number of observations, number of variables, engine(version), observation length) and variable attributes (names,labels, types (numeric or character), lengths, informats, formats)data portion: data values in a rectangular table

rows = observationscolumns = variables

Note: may contain index

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 12 / 21

Page 32: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two portions of a SAS data set

Each SAS data set has two portionsdescriptor portion: contains data set attributes (name, date/timecreated, number of observations, number of variables, engine(version), observation length) and variable attributes (names,labels, types (numeric or character), lengths, informats, formats)data portion: data values in a rectangular table

rows = observationscolumns = variables

Note: may contain index

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 12 / 21

Page 33: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two portions of a SAS data set

Each SAS data set has two portionsdescriptor portion: contains data set attributes (name, date/timecreated, number of observations, number of variables, engine(version), observation length) and variable attributes (names,labels, types (numeric or character), lengths, informats, formats)data portion: data values in a rectangular table

rows = observationscolumns = variables

Note: may contain index

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 12 / 21

Page 34: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two portions of a SAS data set

Each SAS data set has two portionsdescriptor portion: contains data set attributes (name, date/timecreated, number of observations, number of variables, engine(version), observation length) and variable attributes (names,labels, types (numeric or character), lengths, informats, formats)data portion: data values in a rectangular table

rows = observationscolumns = variables

Note: may contain index

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 12 / 21

Page 35: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two portions of a SAS data set

Each SAS data set has two portionsdescriptor portion: contains data set attributes (name, date/timecreated, number of observations, number of variables, engine(version), observation length) and variable attributes (names,labels, types (numeric or character), lengths, informats, formats)data portion: data values in a rectangular table

rows = observationscolumns = variables

Note: may contain index

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 12 / 21

Page 36: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two portions of a SAS data set

Each SAS data set has two portionsdescriptor portion: contains data set attributes (name, date/timecreated, number of observations, number of variables, engine(version), observation length) and variable attributes (names,labels, types (numeric or character), lengths, informats, formats)data portion: data values in a rectangular table

rows = observationscolumns = variables

Note: may contain index

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 12 / 21

Page 37: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two portions of a SAS data set

Each SAS data set has two portionsdescriptor portion: contains data set attributes (name, date/timecreated, number of observations, number of variables, engine(version), observation length) and variable attributes (names,labels, types (numeric or character), lengths, informats, formats)data portion: data values in a rectangular table

rows = observationscolumns = variables

Note: may contain index

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 12 / 21

Page 38: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Viewing Descriptor Portion of SAS Data Sets

Can use one of the following:PROC CONTENTSPROC DATASETS with CONTENTS statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 13 / 21

Page 39: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Viewing Descriptor Portion of SAS Data Sets

Can use one of the following:PROC CONTENTSPROC DATASETS with CONTENTS statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 13 / 21

Page 40: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Viewing Descriptor Portion of SAS Data Sets

Can use one of the following:PROC CONTENTSPROC DATASETS with CONTENTS statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 13 / 21

Page 41: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Outline1 The Language

Language ElementsSAS LogSAS Libraries

2 SAS Data SetsTwo Portions of a SAS Data Set

3 SAS OutputSAS Output: An Example

4 System Options

5 SAS Comments

6 Report Writing—Round One

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 14 / 21

Page 42: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Listing Output and HTML Output

See eg01.sasuse of TITLE and FOOTNOTE statementsSAS formats and FORMAT statements

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 15 / 21

Page 43: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Listing Output and HTML Output

See eg01.sasuse of TITLE and FOOTNOTE statementsSAS formats and FORMAT statements

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 15 / 21

Page 44: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Listing Output and HTML Output

See eg01.sasuse of TITLE and FOOTNOTE statementsSAS formats and FORMAT statements

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 15 / 21

Page 45: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Outline1 The Language

Language ElementsSAS LogSAS Libraries

2 SAS Data SetsTwo Portions of a SAS Data Set

3 SAS OutputSAS Output: An Example

4 System Options

5 SAS Comments

6 Report Writing—Round One

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 16 / 21

Page 46: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Setting System OptionsOPTIONS options;

can be anywhere in the programcan be repeatedmany options are of on/off modes, eg.NUMBER|NONUMBER, DATE|NODATE, CENTER|NOCENTERothers are in the form of option=value, eg.PAGENO=1, LINESIZE=80 (or LS=80), PAGESIZE=40 (orPS=40), YEARCUTOFF=1950, OBS=10, FIRSTOBS=3an option remains in effect until you change itsome options can be locally set/reset in some PROCsuse PROC OPTIONS to view options

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 17 / 21

Page 47: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Setting System OptionsOPTIONS options;

can be anywhere in the programcan be repeatedmany options are of on/off modes, eg.NUMBER|NONUMBER, DATE|NODATE, CENTER|NOCENTERothers are in the form of option=value, eg.PAGENO=1, LINESIZE=80 (or LS=80), PAGESIZE=40 (orPS=40), YEARCUTOFF=1950, OBS=10, FIRSTOBS=3an option remains in effect until you change itsome options can be locally set/reset in some PROCsuse PROC OPTIONS to view options

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 17 / 21

Page 48: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Setting System OptionsOPTIONS options;

can be anywhere in the programcan be repeatedmany options are of on/off modes, eg.NUMBER|NONUMBER, DATE|NODATE, CENTER|NOCENTERothers are in the form of option=value, eg.PAGENO=1, LINESIZE=80 (or LS=80), PAGESIZE=40 (orPS=40), YEARCUTOFF=1950, OBS=10, FIRSTOBS=3an option remains in effect until you change itsome options can be locally set/reset in some PROCsuse PROC OPTIONS to view options

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 17 / 21

Page 49: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Setting System OptionsOPTIONS options;

can be anywhere in the programcan be repeatedmany options are of on/off modes, eg.NUMBER|NONUMBER, DATE|NODATE, CENTER|NOCENTERothers are in the form of option=value, eg.PAGENO=1, LINESIZE=80 (or LS=80), PAGESIZE=40 (orPS=40), YEARCUTOFF=1950, OBS=10, FIRSTOBS=3an option remains in effect until you change itsome options can be locally set/reset in some PROCsuse PROC OPTIONS to view options

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 17 / 21

Page 50: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Setting System OptionsOPTIONS options;

can be anywhere in the programcan be repeatedmany options are of on/off modes, eg.NUMBER|NONUMBER, DATE|NODATE, CENTER|NOCENTERothers are in the form of option=value, eg.PAGENO=1, LINESIZE=80 (or LS=80), PAGESIZE=40 (orPS=40), YEARCUTOFF=1950, OBS=10, FIRSTOBS=3an option remains in effect until you change itsome options can be locally set/reset in some PROCsuse PROC OPTIONS to view options

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 17 / 21

Page 51: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Setting System OptionsOPTIONS options;

can be anywhere in the programcan be repeatedmany options are of on/off modes, eg.NUMBER|NONUMBER, DATE|NODATE, CENTER|NOCENTERothers are in the form of option=value, eg.PAGENO=1, LINESIZE=80 (or LS=80), PAGESIZE=40 (orPS=40), YEARCUTOFF=1950, OBS=10, FIRSTOBS=3an option remains in effect until you change itsome options can be locally set/reset in some PROCsuse PROC OPTIONS to view options

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 17 / 21

Page 52: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Setting System OptionsOPTIONS options;

can be anywhere in the programcan be repeatedmany options are of on/off modes, eg.NUMBER|NONUMBER, DATE|NODATE, CENTER|NOCENTERothers are in the form of option=value, eg.PAGENO=1, LINESIZE=80 (or LS=80), PAGESIZE=40 (orPS=40), YEARCUTOFF=1950, OBS=10, FIRSTOBS=3an option remains in effect until you change itsome options can be locally set/reset in some PROCsuse PROC OPTIONS to view options

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 17 / 21

Page 53: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Setting System OptionsOPTIONS options;

can be anywhere in the programcan be repeatedmany options are of on/off modes, eg.NUMBER|NONUMBER, DATE|NODATE, CENTER|NOCENTERothers are in the form of option=value, eg.PAGENO=1, LINESIZE=80 (or LS=80), PAGESIZE=40 (orPS=40), YEARCUTOFF=1950, OBS=10, FIRSTOBS=3an option remains in effect until you change itsome options can be locally set/reset in some PROCsuse PROC OPTIONS to view options

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 17 / 21

Page 54: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Outline1 The Language

Language ElementsSAS LogSAS Libraries

2 SAS Data SetsTwo Portions of a SAS Data Set

3 SAS OutputSAS Output: An Example

4 System Options

5 SAS Comments

6 Report Writing—Round One

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 18 / 21

Page 55: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two styles of SAS comments

*text;

/*text*/ (note: starts from column 3 for /* in some operatingsystems)

Note:1 Each style can span over several lines2 Combine spaces/indentations with proper comments to create a

clean, readable program style3 Use of Control-/ key shortcut for second style comment and use of

Control-Shift-/ key for uncommenting second style line by line

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 19 / 21

Page 56: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two styles of SAS comments

*text;

/*text*/ (note: starts from column 3 for /* in some operatingsystems)

Note:1 Each style can span over several lines2 Combine spaces/indentations with proper comments to create a

clean, readable program style3 Use of Control-/ key shortcut for second style comment and use of

Control-Shift-/ key for uncommenting second style line by line

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 19 / 21

Page 57: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two styles of SAS comments

*text;

/*text*/ (note: starts from column 3 for /* in some operatingsystems)

Note:1 Each style can span over several lines2 Combine spaces/indentations with proper comments to create a

clean, readable program style3 Use of Control-/ key shortcut for second style comment and use of

Control-Shift-/ key for uncommenting second style line by line

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 19 / 21

Page 58: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two styles of SAS comments

*text;

/*text*/ (note: starts from column 3 for /* in some operatingsystems)

Note:1 Each style can span over several lines2 Combine spaces/indentations with proper comments to create a

clean, readable program style3 Use of Control-/ key shortcut for second style comment and use of

Control-Shift-/ key for uncommenting second style line by line

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 19 / 21

Page 59: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two styles of SAS comments

*text;

/*text*/ (note: starts from column 3 for /* in some operatingsystems)

Note:1 Each style can span over several lines2 Combine spaces/indentations with proper comments to create a

clean, readable program style3 Use of Control-/ key shortcut for second style comment and use of

Control-Shift-/ key for uncommenting second style line by line

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 19 / 21

Page 60: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two styles of SAS comments

*text;

/*text*/ (note: starts from column 3 for /* in some operatingsystems)

Note:1 Each style can span over several lines2 Combine spaces/indentations with proper comments to create a

clean, readable program style3 Use of Control-/ key shortcut for second style comment and use of

Control-Shift-/ key for uncommenting second style line by line

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 19 / 21

Page 61: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Two styles of SAS comments

*text;

/*text*/ (note: starts from column 3 for /* in some operatingsystems)

Note:1 Each style can span over several lines2 Combine spaces/indentations with proper comments to create a

clean, readable program style3 Use of Control-/ key shortcut for second style comment and use of

Control-Shift-/ key for uncommenting second style line by line

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 19 / 21

Page 62: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Outline1 The Language

Language ElementsSAS LogSAS Libraries

2 SAS Data SetsTwo Portions of a SAS Data Set

3 SAS OutputSAS Output: An Example

4 System Options

5 SAS Comments

6 Report Writing—Round One

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 20 / 21

Page 63: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 64: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 65: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 66: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 67: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 68: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 69: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 70: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 71: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21

Page 72: SAS Basic Concepts #1 - wmich.edu Language SAS Data Sets SAS OutputSystem OptionsSAS CommentsReport Writing—Round One SAS Basic Concepts #1 The language, log, output, SAS …

The Language SAS Data Sets SAS Output System Options SAS Comments Report Writing—Round One

Use of PROC PRINT

basic reportselecting variables (VAR statement)subsetting observations (WHERE statement or WHERE= data setoption)column sums (SUM statement)NOOBS option and ID statementBY group listing; with ID statement; with SUM statement; withPAGEBY statementDOUBLE optionLABEL statement together with LABEL procedure statementoptionFORMAT statement

wang (WMU) Basic Concepts 1 S680, Lectures 1&2 21 / 21