BookmarkSubscribeRSS Feed
ashwini2
Fluorite | Level 6

Need a SAS macro to append .txt files.

 

My .txt files are in SAS server SASApp and i am using SAS EG.

 

I have the same number and type of variables in all .txt files and there are about 20 of them.

 

Can anybody help please?

1 REPLY 1
Reeza
Super User

Do they all have headers?

What is your OS and do you have access to it?

 

CAT *.txt > output.txt would work on Unix to append all text files. 

 

Or do you first need to read files and then output them back to single file without headers?

 

You don't need a macro to input all txt files to a single file and then you can use a proc export to export back out but it seems a bit long winded. A System function would be faster if you have that option enabled.

 

Here's code that shows how to read all txt files with one set of code:

 

https://gist.github.com/statgeek/4c27ea9a7ed6d3528835

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1 reply
  • 647 views
  • 4 likes
  • 2 in conversation