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

If I am  reading data from a comma separated text file and in my input step i declare 5 columns and if in the input file there are only 3 comma separated values, will I get exception?

Or will the resultset be created with 5 columns with 3 columns populated and the other columns as null?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

It depends on the settings on your INFILE statement. If you use the TRUNCOVER option then the extra variables will be all missing.  Similarly if there is extra information on the line it will be ignored.

Try this little example.

data x;

infile cards dsd truncover ;

input v1-v5;

cards;

1

1,2

1,2,3

1,2,3,4

1,2,3,4,5

1,2,3,4,5,6

run;

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

It depends on the settings on your INFILE statement. If you use the TRUNCOVER option then the extra variables will be all missing.  Similarly if there is extra information on the line it will be ignored.

Try this little example.

data x;

infile cards dsd truncover ;

input v1-v5;

cards;

1

1,2

1,2,3

1,2,3,4

1,2,3,4,5

1,2,3,4,5,6

run;

stat_sas
Ammonite | Level 13

You will get 5 columns with 3 columns populated remaining as null.

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 797 views
  • 3 likes
  • 3 in conversation