I'm trying to read a tab delimited file with the first row containing a header. My goal is to get the header line only for a large number of datasets that vary in size and construction. Because the header lines are variable in length and can contain hundreds of fields, I can't set the lrecl to the exact width of any header line. When the input length upper limit is less than the length of the header line, the header line imports but is short of the last field; however, when I make the length longer than the length of the header line, so that it goes into line 2, it ignores the header line completely, and acts as though line 2 is the first line of the file.
The code below shows basically what I'm trying to do. I've tried everything I can think of without success. Any feedback is appreciated.
data test;
infile "H:\file.tsv" firstobs=1;
input lines $1-20000;
if _N_ eq 1;
run;
try
data test;
infile "H:\file.tsv" obs=1 lrec=20000 pad;
input lines $1-20000;
run;
try
data test;
infile "H:\file.tsv" obs=1 lrec=20000 pad;
input lines $1-20000;
run;
It was the pad option that did it! Thanks so much for your quick response. Much appreciated.
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.