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;


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
  • 841 views
  • 0 likes
  • 3 in conversation