BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alzioud
Calcite | Level 5

Hello everyone,

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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
;

 

View solution in original post

4 REPLIES 4
ballardw
Super User

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.

alzioud
Calcite | Level 5
i wrote this code and it kept giving me the following message:

the code:
DATA Jan;
infile 'C:\Users\maa285\Desktop\MySAS\Jan.07';
input @1 type 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 $ class 13 $ 85-89 $
class14 $ 90-94 $ class15 $ 95-99;
run;
proc print;
title 'january card';
run;

and the error message is:
LINE and COLUMN cannot be determined.
and:
Expecting a name.

Astounding
PROC Star

Looks like you put an extra space in one variable name:  class 13 should be class13

Tom
Super User Tom
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 20946 views
  • 0 likes
  • 4 in conversation