Hello everyone,
Use the Insert Code or Insert SAS Code icons in the editor to paste in data and/or code so that the format is preserved.
Your INPUT statement has a lot of extra $.
input
type 1-1
code $ 2-3
ID $ 4-9
direction $ 10-10
lane $ 11-11
year $ 12-13
month $ 14-15
day $ 16-17
hour $ 18-19
volume $ 20-24
class1 $ 25-29
class2 $ 30-34
class3 $ 35-39
class4 $ 40-44
class5 $ 45-49
class6 $ 50-54
class7 $ 55-59
class8 $ 60-64
class9 $ 65-69
class10 $ 70-74
class11 $ 75-79
class12 $ 80-84
class13 $ 85-89
class14 $ 90-94
class15 $ 95-99
;
The basic approach for fixed width is to specify the start and end column for each variable:
data want;
infile "file to read" <any needed options like lrecl >;
input
var1 1
var2 2-3
var3 4-9
<etc.>
;
run;
If you are reading character data then use varx $ startcolumn-endcolumn.
Looks like you put an extra space in one variable name: class 13 should be class13
Use the Insert Code or Insert SAS Code icons in the editor to paste in data and/or code so that the format is preserved.
Your INPUT statement has a lot of extra $.
input
type 1-1
code $ 2-3
ID $ 4-9
direction $ 10-10
lane $ 11-11
year $ 12-13
month $ 14-15
day $ 16-17
hour $ 18-19
volume $ 20-24
class1 $ 25-29
class2 $ 30-34
class3 $ 35-39
class4 $ 40-44
class5 $ 45-49
class6 $ 50-54
class7 $ 55-59
class8 $ 60-64
class9 $ 65-69
class10 $ 70-74
class11 $ 75-79
class12 $ 80-84
class13 $ 85-89
class14 $ 90-94
class15 $ 95-99
;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.