Beruflich Dokumente
Kultur Dokumente
Based on
Learning SAS by Example:
A Programmers Guide
Chapters 5 & 6
Topics covered
Formats
Informats
Reading external data
PROC Import
PROC Format
Using formats and labels in DATA vs.
PROC
PROC Datasets
SAS Format
Examples of formats
Pre-formatted
value
Format
Formatted value
2125854
comma10.
2,125,854
52115
dollar24.2
$52,115.00
17526
mmddyy8.
12/26/07
17526
weekdate.
$Gender.
Male
12
AgeGroup.
Under 18
$PassFail.
Passing Grade
Examples of formats
Pre-formatted
value
Format
Formatted value
2125854
comma10.
2,125,854
52115
dollar24.2
$52,115.00
17526
mmddyy8.
12/26/07
17526
weekdate.
$Gender.
Male
12
AgeGroup.
Under 18
$PassFail.
Passing Grade
Examples of formats
SAS Documentation
Format names
<$>format<w>.<d>
Format names
dollar14.2
PROC Import
PROC Import
OUT=
PROC Format
How to create your own formats
PROC Format
PROC Format
PROC Format
value $gender
Input
value
Output
value
PROC Format
Unformatted output
PROC Format
PROC Format
value $gender
value of U would
appear as U in the output
value of m wouldnt
match to 'M' = 'Male'
PROC Format
value YNscale
PROC Format
value $groupdata
using multilabel
formats
PROC Format
value $grades
for character
' ' =
'Missing'
Periods
for numeric
. = 'Missing'
PROC Format
value age
Caution!
Make sure you have clean
data!
What
PROC Format
value wages
Oops!
Whoops!
PROC Format
value wages
600<-high
means 600.000000..01
through upper limit
Using formats
Using formats
Using formats
Using formats
Using formats
Using formats
Using formats
Using formats
Using formats
Using formats
Using formats
Using formats
Using formats
Using labels
Using labels
Using labels
The label
statement
can be used
in either a
DATA or
PROC step
PROC Print
requires a
label option
when you want
to display
labels (instead
of field names)
in the column
header
Using labels
PROC Datasets
PROC Datasets
Labels
Formats
Rename variables
and more
PROC Datasets
PROC Datasets