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