Last edited by Nick Cox ; 28 Aug , Comment Post Cancel. Maarten Buis. I suspect you want: Code:. Thanks for all the comments. Following the "help quotes" section, I was trying to be fancy and encapsulate "" in the macro so I could call the path without typing "" around macro. Strangely, I got an error: Code:. Last edited by Konrad Zdeb ; 29 Aug , Reason: Typo.
What's the problem? Spaces within filenames. What's the solution? Plain double quotation marks " ". Thanks, I'm fighting with this.
If you only have one level of subdirectories, it's not too hard. Just for promotion and because it somehow fits, you may find xls2dta from SSC helpful. It basically implements strategies similar to the ones outlined here and leaves filenames in r that can be used in loops to append the datasets.
Note that it does handle subdirectories yet - if I find the time I might implement some of the things discussed here. Clyde might be thinking of filelist SSC? Best Daniel. Last edited by daniel klein ; 13 Jun , Robert Picard. I'm a bit late to the game but here's the sample code from the filelist help file adapted to import Excel files. This will recursively build a list of all Excel datasets in the current directory type pwd to identify it and its subdirectories.
A loop is then used to import each dataset. The final step is to loop again to append all the Stata datasets. Bert Jung. I realize that you specifically asked for solutions that require not to convert the Excel files to CSV.
But for the record here is an easy-looking and automated solution that can be executed from the command line and hence from within Stata with the shell escape. You can run this in the command line. I am curious if how the various approaches mentioned here compare in terms of processing time. Or maybe it doesn't matter much with "just" files? Cheers, Bert. Kim Lam. Originally posted by Clyde Schechter View Post. For example: The problem is not with your use of macros, its with your use of list.
If there is no variable hello in your data set, then Stata will complain. If there is a variable hello, then you will get a listing of all its values observation-by-observation. Sign up using Email and Password. Post as a guest Name.
Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related 3. Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.
Accept all cookies Customize settings.
0コメント