Help using Base SAS procedures

Error Read

Accepted Solution Solved
Reply
Contributor
Posts: 57
Accepted Solution

Error Read

Hi All,

Sometimes if the last variable is of shorther length than sepcified in length statement SAS doesnt read the value. For example, I have the datafile as:

Sid,Cricket,Basketball,LawnTennis

Tim,Basketball,Golf,Tennis

Phil,Football

If I use the code:

data test1;

length t x y z $10.;

infile 'C:\Documents and Settings\Datafile1.txt' dsd ;

input t x y z $10.;

proc print data = test1;

run;

The cursor whenever reads the last value less than length 10 moves to next line and incorrectly read the values. The output is:

Obs t x y z

1 Sid Cricket Basketball LawnTennis

2 Tim Basketball Golf Phil,Footb

Please sugest.

Regards

SK


Accepted Solutions
Solution
‎09-12-2013 02:32 PM
Super User
Posts: 19,789

Re: Error Read

Posted in reply to Siddharth123

Try the TRUNCOVER option on your input statement and read up on it Smiley Happy

View solution in original post


All Replies
Solution
‎09-12-2013 02:32 PM
Super User
Posts: 19,789

Re: Error Read

Posted in reply to Siddharth123

Try the TRUNCOVER option on your input statement and read up on it Smiley Happy

Respected Advisor
Posts: 3,799

Re: Error Read

TRUNCOVER is not correct for LIST input.

Reeza wrote:

Try the TRUNCOVER option on your input statement and read up on it

Respected Advisor
Posts: 3,799

Re: Error Read

Posted in reply to Siddharth123

The problem is

input t x y z $10.;

$10. turns your LIST(DSD) input into FORMATTED which is incompatable with DSD.

Get rid of $10. since you don't actually need it because you used LENGTH statement to define it or add : modifier :$10. to use informat with list input.

Respected Advisor
Posts: 3,799

Re: Error Read

Posted in reply to Siddharth123

TRUNCOVER is not the correct solution to your problem!

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 197 views
  • 9 likes
  • 3 in conversation