Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: superposed rolled windows


From   "Michael S. Hanson" <mshanson@mac.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: superposed rolled windows
Date   Tue, 27 Jun 2006 12:41:33 -0400

On Jun 27, 2006, at 12:05 PM, irodriguez wrote:

Michael, in your command:
tsset Firms Years // Declare data as a panel
forval i = 1/3 {
local j = `i'-1
gen Profit`i' = F`j'.Profit
}
drop if missing(Profit3)

what is the significate of 1/3, because in the reality i need to make
superposed rolled windows for 5 years and I want to know if I have to change the command and consider 1/5
Yes, the "3" in "1/3" represents the number of years you specified in your earlier message. You could try the following:


tsset Firms Years // Declare data as a panel
local m 5 // Maximum number of years for "rolled windows"
forval i = 1/`m' {
local j = `i'-1
gen Profit`i' = F`j'.Profit
}
drop if missing(Profit`m')


Notice that in addition to the -local- command, the -forval- and - drop- commands have changed vis-a-vis the quoted example. If you decide to go back to a 3-year "superposed rolled windows" (in increase it to, say, 6), you can just change the "5" in the second line to the desired number of years, and the rest of your code will run as intended. (At least as far as I understand what you intend.)


On Jun 27, 2006, at 12:14 PM, irodriguez wrote:


When I try
. tsset empresa ao
stata say
varlist: empresa: string variable not allowed
I have tried with destring command but I don`t know why the data are still
string
Are you sure the data are (now) numeric? -desc empresa- will tell you if they are int(egers) or str(ings). Without knowing more about your data, it is difficult to know if what you really want is - encode- rather than -destring-.

More generally, I encourage you to follow Nick Cox's dictum[*] of explaining exactly what you want to do, and listing the exact commands you have typed in your attempt to do so. An actual (but brief) extract of your data can be helpful to those providing assistance as well. HTH.

-- Mike


[*] My attribution of this premise to Nick is (merely) empirical, as I have often observed him making similar comments in similar circumstances. See the Statalist FAQ at <http://www.stata.com/ support/faqs/res/statalist.html> for a more expansive discussion of this issue.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* 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   |   What's new   |   Site index