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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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