Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: error code with tempfile and save


From   [email protected] (Alan Riley)
To   [email protected]
Subject   st: Re: error code with tempfile and save
Date   Thu, 22 May 2003 08:27:36 -0500

Mitch Wong, M.D. ([email protected]) wrote
> I am using STATA 7 on Win2000 platform and I have been using hotdeck and
> outputst commands. With both programs, I have run into the same error
> code.
> Initially when I run these commands, they work fine.
> However, after several uses (even without changing any of my code), I  get
> the following error:
> **in outputst
> - tempfile tmpdta
> - qui save `tmpdta',replace
> invalid 'and'
> r(198);

My best guess at the source of this problem is that Mitch's temporary
directory has a space in it.  If so, the macro `tmpdta' will contain
a space, and the -save- command will fail since the filename is
not properly quoted.  Change the line in question to read

  qui save `"`tmpdta'"',replace

After making this change, Mitch will need to clear the programs in
memory, if any, so that the old version of the program will not be
used instead of the new one he has changed.  Type

  . discard

to clear the programs in memory, and then try re-running the command.

If Mitch continues to face this error even with the changed line, he
could insert a line of debugging code to try to see exactly what
is going to be executed:

   tempfile tmpdta
   display `"try to execute -qui save `"`tmpdta'"',replace-"'
   qui save `"`tmpdta'"',replace

It appears that Mitch is not using Stata 8.  Stata 8, with -set trace on-,
will automatically show lines with macros in them twice--once unexpanded,
and then again after expansion.  This is a great help in debugging such
problems.


--Alan
([email protected])
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index