I am using preserve / collapse / export / restore in a loop. I then append all the exported files to combine them into one file.
That worked fine for a small number of files, but at this point, it is saving out more than 10k files, and that's very slow and somewhat unnerving.
I was hoping to be able to save the results of the collapse command to a tempfile instead of exporting it.
This is my original code:
Instead, I have tried the following:
I am getting an "invalid file specification" error.
Any suggestions?
Thank you.
That worked fine for a small number of files, but at this point, it is saving out more than 10k files, and that's very slow and somewhat unnerving.
I was hoping to be able to save the results of the collapse command to a tempfile instead of exporting it.
This is my original code:
Code:
foreach v of varlist $varlist { foreach c of global names { preserve collapse (mean) mean`v'=`v' (count) count`v'=`v' gen name1 = "`v'" gen name2 = `"`c'"' export excel name1 name2 mean`v' count`v' using "`v' `g'.xlsx", replace restore } }
Code:
tempfile temptest save `temptest', emptyok foreach v of varlist $varlist { foreach c of global names { preserve collapse (mean) mean`v'=`v' (count) count`v'=`v' append using `temptest', force save using `temptest', replace restore } }
Any suggestions?
Thank you.