SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 688 views
  • 0 likes
  • 4 in conversation