Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: ?bug? in -staticfc-
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: ?bug? in -staticfc-
Date
Mon, 12 Aug 2013 15:08:34 -0400
I am using -staticfc- by Kit Baum, v1.0.1 from 27sep2010 acquired from
SSC with Stata 12.1 and I am getting the following error message:
file __000002.dta could not be opened
after running the following lines (taken from slide 28 of
http://sites.uom.ac.mu/wtochair/attachments/article/3/MRUS4_BC29.slides.pdf):
*********
webuse manufac, clear
staticfc hours L(1/2).caputil lncaputil if tin(1997m1,2008m12), ///
init(48) step(3) gen(cfc4) graph(fig4) replace ///
ti("Three-period-ahead recursive forecasts of hours")
**********
After investigation I see that the following line fails (trace output):
- postfile `postname' `panvar' `ttype'(start end) `keeppost'
`names' using `"`saving'"', `double' `replace' `every'
= postfile __00000H float(start end) __sah cfc4 cfc4_s cfc4_n
using `"__000002"', replace
The filename that Stata complains about (__000002) is the argument
saving, which is coming from the following syntax (in line 51):
saving(`rollf', replace)
And in turn the macro rollf is generated earlier in line 46 with a
tempname statement:
tempname rollf enn tval uplim lowlim
It seems to me that the command -tempname- here is used incorrectly
and should be replaced with -tempfile-. Tempname does not create a
fully-qualified temporary filename, so Stata will be attempting to
create a postfile in the current directory, which in my case happened
to be non-writable:
. pwd
C:\Windows\system32
The second consequence of using tempname instead of tempfile is that
the file temporarily created will not be erased after the command
completes.
The manual for -postfile- explicitly recommends using -tempname- as
the generator for the temporary identifier:
" Two names are specified with postfile: postname is a name assigned
to internal memory buffers, and filename is the name of the file to be
created. ...... We recommend that postname always be obtained from
tempname. ..... Using a temporary filename, too, ensures that the file
will be erased if the user presses Break."
I would interpret that as use tempname for obtaining postname (and
_only_ for postname), and use tempfile for obtaining a filename (and
_only_ filename). Which agrees with what is shown in the help file
for post:
{
tempname memhold
tempfile results
...
postfile `memhold' ... using `results'
}
So far as I can see staticfc.ado does not ever call Stata's tempfile,
which is a symptom of a problem.
Current workaround is to change the directory to somewhere where the
user has write access and clean up that folder manually.
Permanent workaround should be something like:
{
tempfile rollf
tempname enn tval uplim lowlim
}
instead of
{
tempname rollf enn tval uplim lowlim
}
I hope this can be fixed.
Best, Sergiy Radyakin
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/