Statalist


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

RE: st: Question


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Question
Date   Tue, 21 Apr 2009 11:40:06 +0100

Gao Liu's strategy has also been written up in 

SJ-7-3  pr0033  . . . . . . . . . . . . . .  Stata tip 51: Events in
intervals
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q3/07   SJ 7(3):440--443                                 (no
commands)
        tip for counting or summarizing irregularly spaced
        events in intervals

-- but it does require a previous command such as 

generate alliance_no = . 

There can be no -replace- unless the variable already exists. 

Related material is included in 

SJ-7-4  dm0033  . . . . . . Speaking Stata: Counting groups, especially
panels
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q4/07   SJ 7(4):571--581                                 (no
commands)
        discusses how to count panels through reduction commands
        or through tabulation commands and how to overcome
        problems that do not yield easily to these approaches

SJ-7-1  pr0029  . . . . . . . . . . . . . . .  Speaking Stata: Making it
count
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q1/07   SJ 7(1):117--130                                 (no
commands)
        discusses count used with a loop over observations
        or variables

By the way, it helps everyone if you choose informative titles (not, in
this case, "Question"). 

Nick 
n.j.cox@durham.ac.uk 

Gao Liu
=======

Here is one way:

sort firm_name alliance_date

qui forval i = 1/`=_N' {
	count if firm_name  == firm_name [`i'] &
inrange(alliance_date-alliance_date[`i'] , 1, (5*365+1))
	replace alliance_no= r(N) in `i'
}


It may take a while, as it has to run through all observations one by
one, but it should work.

Thomas Zhu or Zhu Yi
====================

> I am working on a project that examines a firm's international
strategic alliance (ISA).
>
> In my huge dataset, I have around 2000 firms forming ISA between
01/01/1989- 0/01/1999. Each firm is likely to form multiple
international strategic alliances during this period.
> For example: Firm A  forms the first strategic alliance on 01/02/1989;
the second on 04/09/1990; the third on 06/09/1997.
>
> What I need to record is the number of new strategic alliances that
the firm forms within 5 years after the focal one.
> For firm A, the number of new strategic alliances that Firm A forms
within 5 years is 1 corresponding to its first strategic alliance on
01/02/1989;
>                 the number of new strategic alliances that Firm A
forms within 5 years is 0 corresponding to  its second strategic
alliance on 04/09/1990 ;
>                the number of new strategic alliances that Firm A forms
within 5 years is 0 corresponding to  its third strategic alliance on
06/09/1997;
>

*
*   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   |   What's new   |   Site index