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
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.
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.
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.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.