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.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.