BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

if I need sas to read in txt file with header and trailer, how to do it?

I saw some program it has the followings:

%LET HEADER_IND=N;

%LET TRAILER_IND=N;

 

do in my case I will put 'Y' instead?

what else do I need?

does it assume one line for header and one line for trailer?

3 REPLIES 3
Patrick
Opal | Level 21

Please provide a sample with header, some data and trailer rows. Use the "bracket icon" to share this text or alternatively attach it as a text file.

Then based on the sample text you share explain/show the desired result (like: is the header the column names that you want to use as variable names or something else).

 

"bracket icon"

Patrick_0-1707189782704.png

 

We need to understand if header and footer are just always the first and last line in your text file, or if there could be multiple lines of header and footer and you have some sort of a line type indicator in column one, or ... Sharing representative sample data will answer all these questions.

 

Ksharp
Super User

That would be better if you post this TEXT file and the OUTPUT you would like to see.

Anyway, here is an example:

 

data have;
infile "c:\temp\outfile.txt" length=len truncover;
input have $varying800. len;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 471 views
  • 0 likes
  • 4 in conversation