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!
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;
Read the log.
data aa00;
informat name $100.;
input name;
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;
Thank you all so much !
I also like the funny cartoon you shared with us.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.