Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

RE: st: Labelling output in 12 month rolling loops

From   "Coetsee.Jane" <[email protected]>
To   <[email protected]>
Subject   RE: st: Labelling output in 12 month rolling loops
Date   Wed, 11 May 2011 16:46:52 -0400

OK, so I have converted yearmonth to a date format using -%t-.  

	format yearmonth %tm

and the variable looks like this:

   786. |   2007m6 |
   787. |   2007m6 |
   788. |   2007m6 |
   789. |   2007m6 |
   790. |   2007m6 |

I can't use the -tsset- command because I have multiple observations per year.
When I try to get a total using: 
	total Outlier_R_NotFHA if twithin(2007m12 , 2009m2m1) & Outlier_R_NotFHA==1
I get the message: 
		 time-series operators not allowed

do I need to total the observations by date to get a series of rolling totals?  Or is there a more elegant way?


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Wednesday, May 11, 2011 4:01 PM
To: [email protected]
Subject: Re: st: Labelling output in 12 month rolling loops

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.


On Wed, May 11, 2011 at 2:57 PM, Coetsee.Jane <[email protected]> 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, replace

*   For searches and help try:
The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer. 
SunTrust is a federally registered service mark of SunTrust Banks, Inc. Live Solid. Bank Solid. is a service mark of SunTrust Banks, Inc. 

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index