DATA Step, Macro, Functions and more

when sas will read second dataline for the first observation to complete.

Accepted Solution Solved
Reply
Contributor
Posts: 44
Accepted Solution

when sas will read second dataline for the first observation to complete.

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

*/


Accepted Solutions
Solution
‎08-24-2014 11:55 AM
Trusted Advisor
Posts: 1,204

Re: when sas will read second dataline for the first observation to complete.

"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


All Replies
Solution
‎08-24-2014 11:55 AM
Trusted Advisor
Posts: 1,204

Re: when sas will read second dataline for the first observation to complete.

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

Contributor
Posts: 44

Re: when sas will read second dataline for the first observation to complete.

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 

Trusted Advisor
Posts: 1,204

Re: when sas will read second dataline for the first observation to complete.

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.

New Contributor
Posts: 4

Re: when sas will read second dataline for the first observation to complete.

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;


☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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