BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
_el_doredo
Quartz | Level 8

Hello Experts,

 

I need to import multiple files from a location. Each files are having different format(xlsx,xls,csv,txt). I need to import all the files into sas. How to import all file which has different format in a location in a single go.

 

My requirement is like below:

 

Path: https://communities.sas.com/files

For instance, In the above path, i am having multiple files.

All_Files.zip (It contains 4 files PY_payment.xlsx , PY_sales.xls , PY_transaction.txt , PY_stores.csv)

payment.xlsx

sales.xls

transaction.txt

stores.csv

 

I need to import all this files into SAS. Can any one please suggest any macro or any method to import all files without doing any manual work.

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You could write a macro that reads the names of all the files in a folder (there are plenty of threads in the SAS Communities on how to do that), then if it is a .xlsx file, the macro imports it one way, if it is a .txt file then the macro imports it another way, and so on.

--
Paige Miller

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Writing such a macro would be more work than importing the files "manually". And I would not trust the results, as you would have to use PROC IMPORT and rely on its guessing.

Concentrate on getting the Excel files imported correctly, which is usually the biggest problem. To get solid and consistent results, save the spreadsheets as csv files and read these with DATA steps.

PaigeMiller
Diamond | Level 26

You could write a macro that reads the names of all the files in a folder (there are plenty of threads in the SAS Communities on how to do that), then if it is a .xlsx file, the macro imports it one way, if it is a .txt file then the macro imports it another way, and so on.

--
Paige Miller

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 433 views
  • 0 likes
  • 3 in conversation