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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

View solution in original post

4 REPLIES 4
Reeza
Super User

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

data_null__
Jade | Level 19

TRUNCOVER is not correct for LIST input.

Reeza wrote:

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

data_null__
Jade | Level 19

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.

data_null__
Jade | Level 19

TRUNCOVER is not the correct solution to your problem!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1621 views
  • 9 likes
  • 3 in conversation