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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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