Introducing SAS Software: Acknowlegements To David Williams Caroline Brophy
Introducing SAS Software: Acknowlegements To David Williams Caroline Brophy
SAS software
Acknowlegements to
David Williams
Caroline Brophy
Statistics
in
Science
Need to know
SAS environment
SAS files (datasets, catalogs etc) & libraries
SAS programs
How to:
Get data in
Manipulate data
Get results out
Statistics
in
Science
Statistics
in
Science
Statistics
in
Science
Log
Output
Explorer
Shows libraries (SAS & Windows), their files, and where you can see data,
graphs
Results
Notepad
A useful place to keep bits of code
Statistics
in
Science
Statistics
in
Science
SAS Programs
data one;
input x y;
datalines;
-3.2 0.0024
-3.1 0.0033
. . .
;
run;
proc print data = one (obs = 5);
run;
proc means data = one;
run;
Statistics
in
Science
DATA step
creates SAS data set
PROC steps
process data in data set
Step Boundaries
SAS steps begin with a
DATA statement
PROC statement.
Statistics
in
Science
Step Boundaries
data seedwt;
input oz $ rad wt;
datalines;
Low 118.4 0.7
High 109.1 1.3
Low 215.2 2.9
run;
proc print data = two;
proc means data = seedwt;
class oz;
var rad wt;
run;
Statistics
in
Science
Recommended steps!
1) Submit all (or selected) code by
F4
Click on the runner in the toolbar
2) Read log
3) Look in output window
if you expect code to produce output
4) Problems
Bad syntax
Missing ; at end of line
Missing quote at end of title (nasty!)
Statistics
in
Science
Statistics
in
Science
Statistics
in
Science
Statistics
in
Science
Statistics
in
Science
work library
SAS data sets with a single part name like
oz, wp or mybestdata99
1)
2)
3)
Statistics
in
Science
. . . More later!
Statistics
in
Science
SAS variables
There are two types of variables:
character
of storage by default.
Eight bytes of floating point storage provide space for 16 or
17 significant digits.
You are not restricted to 8 digits.
Dont change the 8 byte length!
Statistics
in
Science
SAS variables
OUTPUT
The CONTENTS Procedure
Alphabetic List of Variables and Attributes
#
1
2
3
Statistics
in
Science
Variable
oz
rad
wt
Type
Char
Num
Num
Len
8
8
8
SAS names
for data sets & variables
can be 32 characters long.
can be uppercase, lowercase, or mixed-case
but are not case sensitive!
must start with a letter or underscore. Subsequent characters can
be letters, underscores, or numeric digits
- no %$!*&#@ or spaces.
Statistics
in
Science
FirstName
JobTitle
Salary
TORRES
LANGKAMM
SMITH
WAGSCHAL
TOERMOEN
JAN
SARAH
MICHAEL
NADJA
JOCHEN
Pilot
Mechanic
Mechanic
Pilot
50000
80000
.
77500
65000
A character missing
value is displayed as
a blank.
Statistics
in
Science
A numeric
missing value
is displayed as
a period.
SAS syntax
Not case sensitive
Each line usually begins with keyword
and ends with ;
Common Errors:
Forget ;
Miss-spelt or wrong keyword
Missing final quote in title
Statistics
in
Science
Comments
1.
2.
3.
Alternative:
* comment ;
Statistics
in
Science
SAS
Statistics
in
Science
Statistics
in
Science
1)
2)
oz $ rad wt;
0.7
1.3
2.9
Note:
1. oz is text variable so requires $
2. No missing values
3. Values of oz
Statistics
in
Science
Statistics
in
Science
Statistics
in
Science
treat
ysquared
logy
logy_base10
t1
10.0
100.00
2.30259
100.0
10000.00
4.60517
-10.0
100.00
0.0
0.00
0.1
0.01 -2.30259
-1
Data Screening
Statistics
in
Science
Data Screening
checking input data for gross errors
Statistics
in
Science
SAS syntax
MEANS syntax
Statistics
in
Science