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: FORVAL loop incomplete
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: FORVAL loop incomplete
Date
Mon, 11 Nov 2013 17:41:11 +0000
You have to install -srootfix- as such. What does Stata say when you
type -which srootfix-
Nick
[email protected]
On 11 November 2013 16:58, Francis, Richard N <[email protected]> wrote:
>> Nick,
>>
>> If srootfix comes back with "invalid command" ....
>>
>> Is that saying Stata does not recognize srootfix??
>>
>> Rick
>>
>> -----Original Message-----
>> From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
>> Sent: Monday, November 11, 2013 9:33 AM
>> To: [email protected]
>> Subject: Re: st: FORVAL loop incomplete
>>
>> The fix is another way to do the same thing.
>>
>> destring gvkey, replace
>>
>> egen id = group(gvkey), label
>>
>> gen date = yq(year, fqtr)
>>
>> tsset id date, quarterly
>>
>> su id, meanonly
>>
>> *create file to contain new appended variable
>>
>> *save new
>>
>> g Z14 = .
>> g Z24 = .
>> g Z34 = .
>> g Z4t = .
>> g Z3t = .
>> g Z2t = .
>> g Z1t = .
>>
>> forval i = 1/`r(max)' {
>> srootfix fcf if id == `i'
>> return list
>> ereturn list
>> replace Z14 = r(Z14) in `i'
>> replace Z24 = r(Z24) in `i'
>> replace Z34 = r(Z34) in `i'
>> replace Z4t = r(Z4t) in `i'
>> replace Z3t = r(Z3t) in `i'
>> replace Z2t = r(Z2t) in `i'
>> replace Z1t = r(Z1t) in `i'
>> append using new
>> }
>> Nick
>> [email protected]
>>
>>
*
* 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/