Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Labelling output in 12 month rolling loops


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Labelling output in 12 month rolling loops
Date   Wed, 11 May 2011 21:00:56 +0100

There are problems on several levels here.

1. The command that is failing is

              label val `i' lbl

as when first called that takes the form

             label val 1 lbl

which is quite illegal.

2. Before that, the line

                label define lbl `i' "'T'", modify

is legal but always assigns the text 'T' to a value label. Presumably
your intention was to use the local macro T, which would be achieved
with the call `T' (the important difference is the opening left
quotation mark `). But as you defined the local macro T earlier the
effect would be that _every_ value label would just be the literal
text "in date". There is absolutely no way that would achieve the
effect you desire of going off to look in the variable -date-; that is
just fantasy syntax.

3. The -if- qualifier

if yearmonth>= 576+`i' & yearmonth<588+`i'

just will not work as Stata will not do calculations on the fly in
this way, although there are other ways to do it.

4. You are evidently using user-written commands -eststo- and
-esttab-, which you are asked to explain, saying where they come from.
I don't use them, and can't provide support on how to use them.

All that said, the issue appears to be labelling your months with
intelligible dates. Just arranging that -yearmonth- has an appropriate
date format (see -help format-) and exporting that together with your
other variables is presumably the way forward. There is no need to
write a loop to do that.

Nick

On Wed, May 11, 2011 at 2:57 PM, Coetsee.Jane <Jane.Coetsee@suntrust.com> wrote:

> I am running 12 month rolling totals on the dummie variables
> representing outliers for a model.  The variable "yearmonth" is a
> numeric stata date type variable and "date" is a string variable that I
> want to use as  labels for the output.   The problem with my 12 month
> rolling code is that it produces a file with the totals I want but
> without dates stating to which year end the total corresponds.  I am
> trying to do this using the "label" command.  When I run the code below
> I get the error message "1 invalid name"
>
> local T in date
> eststo clear
> qui foreach i of num 1/24 {
>                 label define lbl `i' "'T'", modify
>                 label val `i' lbl
>                 eststo:total Outlier if yearmonth>= 576+`i' &
> yearmonth<588+`i' & Outlier_R_NotFHA==1
>                 }
>                 }
>                 esttab using Rolling_RNFHA_Outlier1.tab, replace
>
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index