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: 417
Accepted Solution

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

Hi Everyone,

I follow this below code to import all CSV file 

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

It works but I find a very strange issue.

1 of the datafile is not import even though the name of this file is in the list.

SAS create test1, test2, then test4. it totally skip to import that file (which supposed to be test3)

 

I rename the file, still not work. 

I save as a new name, SAS import the new file but still refuse to import the old file.

I also try to run this file individually using no-macro code, it works

 

In log, there is no sign for this file being mentioned.

 

I wonder if you have any idea what is going on with that gosh file.

 

Thank you,

HC


Accepted Solutions
Solution
‎09-13-2017 10:56 AM
Super User
Super User
Posts: 7,970

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

Yep, as a good rule for using computers - never put special characters, spaces, tabs or anything other than alphanumeric characters in a filename. 

View solution in original post


All Replies
PROC Star
Posts: 7,480

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

My initial guess is that the file was open when you tried to import it.

 

Art, CEO, AnalystFinder.com

 

PROC Star
Posts: 7,480

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

If that wasn't it, I'd first send the command:

options mprint mologic symbolgen;

 

and then run the macro

 

The carefully review the expanded log you'll receive

 

Art, CEO, AnalystFinder.com

 

Super User
Posts: 19,822

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

The file is in the data set list? 

 

 

Super User
Super User
Posts: 7,970

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

Right, let me repeat for the hundreth time, 

CSV is not Excel

CSV=Comma Separated Variable file, it is a text file file with a bit of structure to indicate where data starts/stops.  It is nothing to do with Excel!

 

 

Now, for your question, as we cannot see the files, nor the run, please provide a log of the run, and if possible the dataset of list, what I suspect is the name for the dataset is not valid, so its not being written.

Super Contributor
Posts: 417

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

I guess the problem is that: the file name:

"Strk, Tiexrabc 8.3.17_Expense Reimbursement Form"  contains a comma "," so SAS somehow doesnt read it.

I put "," in other file name and SAS skip it as well.

 

Please confirm if it is the right cause.

 

 

HC

Solution
‎09-13-2017 10:56 AM
Super User
Super User
Posts: 7,970

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

Yep, as a good rule for using computers - never put special characters, spaces, tabs or anything other than alphanumeric characters in a filename. 

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 216 views
  • 3 likes
  • 4 in conversation