DATA Step, Macro, Functions and more

Import all Excel files in a folder and add all to 1 final file

Accepted Solution Solved
Reply
Super Contributor
Posts: 503
Accepted Solution

Import all Excel files in a folder and add all to 1 final file

Hello Everyone,

I have 1 folder with multiple Excel (xlsx) files with random name.

I want to import all of them and put to a final file.

Can anyone help me how to get it done?

My idea is below.

Many thanks!

HC

 

proc import datafile="C:\Users\document\*.xlsx"
out=_tempfile dbms=xlsx replace;
getnames=yes;
run;

data final; set final _tempfile;run;

Accepted Solutions
Solution
‎09-12-2017 03:08 PM
Super User
Posts: 22,843

Re: Import all Excel files in a folder and add all to 1 final file

Not a particular efficient solution, especially in terms of getting all the files but the rest is about the same. 

https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type

View solution in original post


All Replies
Solution
‎09-12-2017 03:08 PM
Super User
Posts: 22,843

Re: Import all Excel files in a folder and add all to 1 final file

Not a particular efficient solution, especially in terms of getting all the files but the rest is about the same. 

https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type

Super Contributor
Posts: 503

Re: Import all Excel files in a folder and add all to 1 final file

It works nicely.

Thank you.

HC

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 767 views
  • 0 likes
  • 2 in conversation