Académique Documents
Professionnel Documents
Culture Documents
Konda
Department of Statistics and Applied Probability
UCSB
DATA statement
INFILE or DATALINES statement
INPUT statement
Class Exercise
The data set below contains the 2010 population estimates
(in millions) of several U.S. states. Which type of input
statement would be used for the data set below?
Calif 36.9
Texas 24.8
NewYork 19.5
Florida 18.5
Illinois 12.9
36.9
24.8
19.5
18.5
12.9
10
11
12
13
14
each observation
This is called fixed or aligned
15
36,961,664
24,782,302
19,541,453
18,537,969
12,910,409
16
17
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
0 1 5
1 0 / 2 5 / 1 2
L AX
14
1 6 3
observation
Flight $3
Date $8
Dest $3
FirstClass N8
Economy N8
015
10/25/12
LAX
14
163
18
data work.dfwlax;
infile 'raw-data-file';
input Flight $ 1-3 Date $ 4-11
Dest $ 12-14 FirstClass 15-17
Economy 18-20;
run;
SAS prepares the input buffer
PSTAT 130 Summer 2015 - Konda
19
Lecture Overview
A Look Behind Data Step Processing
Compilation and Execution
More on INPUT statements
Examining Errors
Data and Programming Errors
20
21
Flight $3
Date $8
2
1
Dest $3
3
1
FirstClass N 8
Economy N8
Empty Input
Buffer
Empty Program
Data Vector
It then loads the first line of data into the input buffer,
1 4
Flight $3
Date $8
Dest $3
FirstClass N 8
Economy N8
509
3/21/10
LAX
14
163
Record output to
SAS Dataset
22
23
data students;
input @1 Name $8. @9
Enroll mmddyy8.;
datalines;
David
Male
19
Amelia Female
23
Ashley Female
20
Jim
Male
26
;
run;
06/18/10
08/02/10
09/14/10
08/26/10
24
25
Class Exercise
Write an input statement to read in the following data,
Asst
Prof
Assoc
$56,000
$92,000
$78,000
PSTAT130
PSYCH118
POLI125
09/23/10
09/24/10
09/27/10
26
27
28
29
30