Good Day,
First time poster. Any assistance would be gratefully appreciated.
Question 1. what can I do to have STATA insheet a series of non-.RAW
files using the foreach command?
Consider the following example:
foreach file in "F:\Projects\C-6430
\Dissertation\Montclair\100000268936" "F:\Projects\C-6430
\Dissertation\Montclair\100000566461"
insheet using "`file'", clear tab
display "`file'"
save "`file'", replace
}
Stata will read in the files and display the names if the files
are .raw. Then, STATA will save the files as .dta
Yet, the actual files are not .raw, they are .dat. And, there are far
more than those presented in this example which would make renaming
each extension for each file (by the way they are also in different
folders) quite painful.
I have tried a number of combinations of quotes attempting to get at:
insheet using "`file'.dat", clear tab
display "`file'.dat"
save "`file'.dta", replace
But clearly that isn't (nor any other variations that I've tried) the
correct quotes method to use. Moreover, if I were to just in the
macro file using "F...\100000268936.dat", but then I can't save the
file as dta using the macro command "`file'" without saving the
file .dat
In a perfect world, I could tell STATA to replace .raw as the default
to insheet with .dat and that would solve everything. So, if anyone
can tell me how to do that... or any other potential solution for
this dilemma, I would be very thankful.
Question 2: (If you haven't had enough) Is there a way (preferably
within the foreach command) to have STATA insheet an ASCII file (and
later save as STATA format) every file in a folder (without specifying
each individual file name)?
Again, any assistance would be greatly appreciated.
With thanks,
Donnell Butler
Princeton University
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/