Need a SAS macro to append .txt files

Reply
Occasional Contributor
Posts: 19

Need a SAS macro to append .txt files

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?

Grand Advisor
Posts: 17,308

Re: Need a SAS macro to append .txt files

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

Ask a Question
Discussion stats
  • 1 reply
  • 244 views
  • 4 likes
  • 2 in conversation