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]

From |
"Coetsee.Jane" <Jane.Coetsee@suntrust.com> |

To |
<statalist@hsphsun2.harvard.edu> |

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? Thank-you, -Jane. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Wednesday, May 11, 2011 4:01 PM To: statalist@hsphsun2.harvard.edu 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. 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/ LEGAL DISCLAIMER 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. [ST:XCL] * * 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/

**Follow-Ups**:**Re: st: Labelling output in 12 month rolling loops***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: Labelling output in 12 month rolling loops***From:*"Coetsee.Jane" <Jane.Coetsee@suntrust.com>

**Re: st: Labelling output in 12 month rolling loops***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: Labelling output in 12 month rolling loops** - Next by Date:
**st: Adding wald test using esttab.** - Previous by thread:
**Re: st: Labelling output in 12 month rolling loops** - Next by thread:
**Re: st: Labelling output in 12 month rolling loops** - Index(es):