As noted by @Roberto Ferrer, the program is difficult to read. (Some of us have tried to improve the presentation but not with the intent of fixing code errors.) Indeed it contains numerous fatal small errors, principally near randomness in the use of single quotation marks in the referencing of local macros
` '
Quotation marks that you need are missing; extra quotation marks that would be fatal in your case have been supplied; you use the wrong quotation marks in some lines. The claim that the program works is unsubstantiated therefore and appears absurd. At best, you have presented your program very carelessly and unprofessionally.
There is one central misunderstanding that undermines the intent of the program totally, however. A temporary file as named by tempfile
and created somehow within a program will not survive beyond the end
of a program. That is the precise sense in which a file is temporary. So, it is futile to imagine that using temporary files is a way to save
files for any later purpose. Even if it were, there would be precisely no gain over using a file directly.
A marginal exception is that sometimes if a Stata session crashes, temporary files linger beyond the end
of a program, but as that is essentially unpredictable, it has no bearing on your project.
A further extraordinary feature of your program is at best what it would do is save
the current dataset in one temporary file. There is nothing in your code that has anything whatsoever to do with multiple files.
Wanting to mimic what SAS does is not a transparent aim to Stata programmers; my guess is that the fraction of Stata programmers familiar with SAS is of the order of 1%, so you would need to explain more unless you are aiming at a readership of that 1%. To make this into a question of any value, you would minimally need to explain what by handling several datasets at the same time actually would mean in Stata terms. Stata's idea is that datasets that you want to relate can be combined using append
, merge
, and other such commands, but that does not seem anything at all like what you want.
On advice to avoid tokenize
: I don't think that is clear at all. What advice from whom, and more importantly why?
If you want to show us a program that works, and ask for advice on how to extend it, that could make sense, but at present it appears that your idea is impossible from the outset. Presenting code strewn with errors and claiming that it works is very puzzling.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…