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.

 

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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