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?
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;
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;
You will get 5 columns with 3 columns populated remaining as null.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.