BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GeorgeSAS
Lapis Lazuli | Level 10
data aa00;
input name $100.;
cards;
A20GE
ABSSVC
ADTPCLS
ADULTPED
AGEGP
APPTNO
AREANAME
BUCKET
BUSLIN
BUSLINE
BUSTYP
BUSTYPE
CLASSCD
CL_FAC
CL_MOB
CNTYNAME
CSANAME
DEDCT
DEP2CCIN
EDPFACID
;run;

if I change $100. to $45. it will be ok. can anyone explain the magic in it?

 

Thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

https://condenaststore.com/featured/then-dont-do-that-robert-leighton.html

 

Since your lines are 80 characters or less when you try to read 100 characters from them SAS will go to the next line to find enough characters.

Either add an INFILE statement so that you can specify the TRUNCOVER option to prevent SAS from going to a new line,

 

data aa00;
  infile cards truncover ;
  input name $100.;
cards;

or since you seem to want to read the whole line you could just use the _INFILE_ buffer.

data aa00;
  length name $100 ;
  input;
  name = _infile_;
cards;

or don't use such a large informat. Note in-line data (CARDS/DATALINES) will have a LRECL that is a multiple of 80. 

data aa00;
  input name $80. ;
cards;

 

View solution in original post

4 REPLIES 4
Reeza
Super User

Read the log. 

 

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.AA00 has 10 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
When you specify $100 inline (on the INPUT statement) like that SAS is trying to find 100 characters. If you're trying to specify the variable length, try using a LENGTH or INFORMAT instead.
 
data aa00;
informat name $100.;
input name;
Tom
Super User Tom
Super User

https://condenaststore.com/featured/then-dont-do-that-robert-leighton.html

 

Since your lines are 80 characters or less when you try to read 100 characters from them SAS will go to the next line to find enough characters.

Either add an INFILE statement so that you can specify the TRUNCOVER option to prevent SAS from going to a new line,

 

data aa00;
  infile cards truncover ;
  input name $100.;
cards;

or since you seem to want to read the whole line you could just use the _INFILE_ buffer.

data aa00;
  length name $100 ;
  input;
  name = _infile_;
cards;

or don't use such a large informat. Note in-line data (CARDS/DATALINES) will have a LRECL that is a multiple of 80. 

data aa00;
  input name $80. ;
cards;

 

GeorgeSAS
Lapis Lazuli | Level 10

Thank you all so much !

 

I also like the funny cartoon you shared with us.

ChrisBrooks
Ammonite | Level 13

In my opinion you should ALWAYS set an explicit length for your character variables. If you don't you could end up with the same variable on different files having different lengths which could lead to problems if you try to to append or merge them.

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
  • 1274 views
  • 4 likes
  • 4 in conversation