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]
Re: st: RE: RE: RE: RE: Extracting results from -rolling- in one file per window
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: RE: RE: RE: RE: Extracting results from -rolling- in one file per window
Date
Mon, 17 Mar 2014 01:23:33 +0000
You are confusing the syntax for globals and locals. For example,
given your initial assignment
global counter "0"
(It's purely a style point, but when I want a -global- to hold numbers
I would go
global counter = 0
but the effect of your statement is the same in this case.)
The next use is legal:
global counter=`counter'+1
But only by accident is it right. Stata sees a reference to -local-
called `counter'; it doesn't exist, so Stata just skips that and sees.
global counter = +1
and that's OK. But you meant
global counter = $counter + 1
But later when you go
save `counter', replace
there's still no -local- with that name, so Stata sees
save, replace
and that throws you out.
This is all documented in [U] in the first sections on macros. You
have to read and understand that stuff to be able to write programs.
Nick
[email protected]
On 17 March 2014 01:13, Micha Schildmann <[email protected]> wrote:
> Dear Joe,
>
> again your reply was most welcomed. I tried the following code
>
> global counter "0"
> capture program drop rollingwindow
> program rollingwindow
>
> global counter=`counter'+1
> global tflist ""
>
>
> foreach var of varlist *SA{
> reg Mid `var'
> tempfile tfcur
> parmest, idstr("`var'") saving(`"`tfcur'"', replace) flis(tflist)
> }
> preserve
> clear
> append using $tflist
> sencode idstr, gene(xvar)
> lab var xvar "X-variable"
> keybygen xvar, gene(parmseq)
> drop if parmseq==2
> egen rank = rank (-t)
> drop if rank>30
> save `counter', replace
> restore
> end
>
>
> rolling, window(4) stepsize (4) recursive: rollingwindow
>
> but I get the following error
>
> - save `counter', replace
> = save , replace
> invalid file specification
>
> when enabling trace.
>
> This confuses me as I tried something very similar and it worked.
>
> Do you or anyone else have any idea what could cause this error?
>
> Best regards
> Micha
>
> *
> * 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/
*
* 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/