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.

 

Become an Explorer! Join SAS Analytics Explorers to learn and complete challenges that earn rewards!

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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