Basic Output (with the Print Procedure) - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Basic Output (with the Print Procedure)

Description:

The print procedure is primarily used to display raw data. ... One can also subset output using a where statement in a procedure (or data step) ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 24
Provided by: BLU54
Category:

less

Transcript and Presenter's Notes

Title: Basic Output (with the Print Procedure)


1
Basic Output (with the Print Procedure)
  • STT 305

2
The 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.

3
General System Options
  • Options statement
  • options SAS-system-options

4
Customizing 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
6
The 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.

7
Example
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
8
Output
Specifying the by variable in the VAR
statement is redundant
9
More
  • 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
10
Output
11
Titles 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).

12
More 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.

13
Labels
  • 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.

14
The 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.

15
Example
  • Add the command
  • label dam 'Dam (1Yes)'
  • inside the PROC PRINT to get

16
Output
17
Where 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

18
Output
19
Exercises
  • 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

20
SFO_Flights Output (Page 1 of 2)
21
Projects Output (Page 1 of 45)
22
Projects Output (Page 2 of 45)
23
Projects Output (Page 45 of 45)
Write a Comment
User Comments (0)
About PowerShow.com