BookmarkSubscribeRSS Feed
maliksmom2000
Obsidian | Level 7

How do I import a large number of .txt files into SAS Enterprise at once?  The import data function will take way too long.  The column names begin in B1 and the dataset for each begins in B4.  There's 3163 lines in each file.

2 REPLIES 2
Reeza
Super User
Text files don't have B1 and B4 - that's excel terminology.

Are all the files in the same folder? Are they in different folders?
Is each file going to a different data set or are they getting combined?
Are all the variables the same in each file?

And do you have a program to read a single file correctly - that's what you need to start out with. And it should be via a data step, not proc import or a task.

Assuming all files are in one folder and they're all going to the same data set, the approach I discuss here is the same in EG but you still that that first part - the INPUT statements to read the file correctly first. Then replace the INPUT and INFILE in the link below and you should be good to go.
https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-tex...
ChrisHemedinger
Community Manager

Here's a tutorial (about 15 minutes) that shows how to start with the Import Data task, create a code template, modify it using the INFILE with a wildcard spec to pull multiple files, and keep track of which records come from which files.

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 3114 views
  • 2 likes
  • 3 in conversation