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

I did my work but could not confirm the answer.anyone's help is appreciated.

title 'v1 length 20 reading the same line' ;

data testing;

infile datalines ;

input      v1 $ 20.;

datalines;

aa

bb xx

cc

dd zz

;

proc print;run;

title 'v1 length 100 reading the different line' ;

data testing;

infile datalines ;

input      v1 $ 100.;

datalines;

aa

bb xx

ccd zz

;

run;

proc print;run;

/*                             v1 length 20 reading the same line                                32

                                                                         10:37 Monday, August 24, 2009

                                             Obs    v1

                                              1     aa

                                              2     bb xx

                                              3     cc

                                              4     dd zz

                               v1 length 100 reading the different line                             33

                                                                         10:37 Monday, August 24, 2009

                                             Obs     v1

                                              1     bb xx

                                              2     dd zz

*/

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

"v1 length 100 reading the different line" because typical record length is 80 columns. If you put $ 80 or less then you will be fine. Otherwise use truncover option in infile statement.

View solution in original post

4 REPLIES 4
stat_sas
Ammonite | Level 13

"v1 length 100 reading the different line" because typical record length is 80 columns. If you put $ 80 or less then you will be fine. Otherwise use truncover option in infile statement.

rajeshm
Quartz | Level 8

hi,

thanks for the reply.

I did noticed that anywhere (record length is 80).  

I just remember this, if anything wrong ,please let me know.

if reading from external file default length=256 and

if reading from datalines     default length=80 

stat_sas
Ammonite | Level 13

SAS always pads the data records that follow the DATALINES statement to a fixed length in multiples of 80. LRECL= option specifies the default logical record length to use for reading and writing external files. It has default value of 256.

sandra17
Calcite | Level 5

use truncover option infile statement like this

title 'v1 length 20 reading the same line' ;

data testing;

infile datalines truncover;

input v1 $20.;

datalines;

aa

bb xx

cc

dd zz

;

proc print;

run;

title 'v1 length 100 reading the different line';

data testing;

infile datalines truncover;

input v1  $ 100.;

datalines;

aa

bb xx

ccd zz

;

run;

proc print;

run;


hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1385 views
  • 0 likes
  • 3 in conversation