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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

try

 

data test;
infile "H:\file.tsv" obs=1 lrec=20000 pad;
input lines $1-20000; 

run;

View solution in original post

2 REPLIES 2
ballardw
Super User

try

 

data test;
infile "H:\file.tsv" obs=1 lrec=20000 pad;
input lines $1-20000; 

run;

Ryanb2
Quartz | Level 8

It was the pad option that did it!  Thanks so much for your quick response.  Much appreciated.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 3726 views
  • 0 likes
  • 2 in conversation