Title: Basic Output (with the Print Procedure)
1Basic Output (with the Print Procedure)
2The Print Procedure
- The print procedure is primarily used to display
raw data. - In its most basic form, it simply sends the data
to the output window. - Print does allow for some levels of customization
and summarization.
3General System Options
- Options statement
- options SAS-system-options
4Customizing the Print Procedure
- General Syntax
- proc print dataSAS-data-set options
- var variable-list
- by ltdescendinggt variable-list
- pageby variable-list
- id variable-list
- sum variable-list
- sumby variable-list
- run
- May also include label and/or format statements.
5- proc print dataSAS-data-set options
- var variable-list
- by ltdescendinggt variable-list
- pageby variable-list
- id variable-list
- sum variable-list
- sumby variable-list
- run
label Column headings will use variable
labels. noobs observation column will be
suppressed.
Lists variables that you wish to displayin the
order for display
Groups output by variable(s) specified. Must be
sorted on those variables using PROC SORT.
Breaks pages by levels of variable(s) listed.
Variable(s) must have appeared in by statement.
Provides identifier for each observation printed.
If variable(s) specified are by variable(s),
identifier is printed once per group
Provides column totals for variable(s) listed.
Gives totals by any variable(s) listed in by
statement.
Provides totals only for by group variable(s)
listed
6The SORT Procedure
- The sort procedure sorts a data set by the values
of the listed variable(s). - Syntax
- proc sort dataSAS-data-set ltoutSAS-data-set gt
- by ltdescending gt variable1 ltdescending gt
variablek - run
- Sorts by first variable listed, then by the
second variable within each group of the first,
and so on.
7Example
Groups output by the specified variable
Suppresses printing of the observations column
- proc sort datastt305.fish outwork.fish_sorted
- by lt
- run
- proc print datafish_sorted noobs
- by lt
- var lt dam elv sa hg
- run
Chooses columns/variables to display
8Output
Specifying the by variable in the VAR
statement is redundant
9More
- proc print datafish_sorted noobs
- by lt
- id lt
- var lt dam elv sa hg
- sum hg
- run
Removes the line separators between groups and
labels each in the left column
Provides totals, by groups and overall, for the
specified variables
10Output
11Titles and Footnotes
- General form
- titlen title text
- footnoten footnote text
- Titles appear at the top of the page, notes at
the bottom (default title is The SAS System) - n can be any whole number between 1 and 10 (title
is equivalent to title1).
12More on Titles and Footnotes
- Titles remain in effect for the SAS session
unless they are cancelled or changed. - Submission of a titlen statement
- Replaces previous title with same number
- Removes all titles with higher number
- Submission of a null title statement (title)
cancels all titles. - Above works same for footnotes.
13Labels
- Labels can be provided to replace variable names
in certain displays. - The addition of the label option to the proc
print line causes labels to be displayed in place
of variable names.
14The Label Statement
- The label statement applies a label to be written
in place of the variable name for display - label variable1label1 variable2label2
- Labels assigned using the label statement in a
procedure are temporaryonly in effect for that
procedure.
15Example
- Add the command
- label dam 'Dam (1Yes)'
- inside the PROC PRINT to get
16Output
17Where Processing
- One can also subset output using a where
statement in a procedure (or data step) - where expression
- Procedure only processes records for which the
expression is true - Example Add the following to your last PRINT.
-
- where hg ge 0.5
18Output
19Exercises
- Use the SFO_Flights data set to create the output
shown in the following slides - Use the Projects data set to create the output
shown in the following slides
20SFO_Flights Output (Page 1 of 2)
21Projects Output (Page 1 of 45)
22Projects Output (Page 2 of 45)
23Projects Output (Page 45 of 45)