data dmv;
input
ID 3-5 @
Score 13-14 @
Age 6-7 @
Code 8-12 @
State 1-2 @;
datalines;
AR373535867443
CO884198099142
CO844117922301
CT892260212694
GA544146397264
FL116356242135
FL012766334163
IA284575080076
MO201819486741
MN333660025825
NC521620806587
NC391625607716
NY242148623172
OH498277408248
TX334618334735
;
run;
TITLE "input data";
PROC PRINT DATA=dmv;
RUN;
Note that State is a string, and ID and Code should probably also be handled as character, so use this:
data dmv;
input
@3 ID $3.
@13 Score 2.
@6 Age 2.
@8 Code $5.
@1 State $2.
;
datalines;
AR373535867443
CO884198099142
CO844117922301
CT892260212694
GA544146397264
FL116356242135
FL012766334163
IA284575080076
MO201819486741
MN333660025825
NC521620806587
NC391625607716
NY242148623172
OH498277408248
TX334618334735
;
What do you thing those @ in the INPUT statement are for?
To SAS it looks like you started with:
input id 3-5 @SCORE ....
So the @ score means move to the column number of the value of SCORE. Just like @ 10 means move to column 10.
So it is expecting the name of the variable you want to read from columns 13 to 14 to appear between the variable that the @ pointer motion is using and the 13.
Remove the @ 's .
input
ID 3- 5
Score 13-14
Age 6- 7
Code 8-12
State 1- 2
;
Note it is probably easier if you have some reason for wanting ID to be the first variable instead of the second to just tell SAS that directly and then have the INPUT statement read the variables in the order they actually appear on the line.
data dmv;
length ID Score Age Code State 8;
input
State 1- 2
ID 3- 5
Age 6- 7
Code 8-12
Score 13-14
;
Or
data dmv;
length ID Score Age Code State 8;
input
State 2.
ID 3.
Age 2.
Code 5.
Score 2.
;
Note that State is a string, and ID and Code should probably also be handled as character, so use this:
data dmv;
input
@3 ID $3.
@13 Score 2.
@6 Age 2.
@8 Code $5.
@1 State $2.
;
datalines;
AR373535867443
CO884198099142
CO844117922301
CT892260212694
GA544146397264
FL116356242135
FL012766334163
IA284575080076
MO201819486741
MN333660025825
NC521620806587
NC391625607716
NY242148623172
OH498277408248
TX334618334735
;
"STAT" is character variable ,therefore you need $ to define it .
data dmv;
input ID 3-5
Score 13-14
Age 6-7
Code 8-12
State $ 1-2 ;
datalines;
AR373535867443
CO884198099142
CO844117922301
CT892260212694
GA544146397264
FL116356242135
FL012766334163
IA284575080076
MO201819486741
MN333660025825
NC521620806587
NC391625607716
NY242148623172
OH498277408248
TX334618334735
;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.