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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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