Statalist


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

RE: st: STATA code for identifying similar observations within group id


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: STATA code for identifying similar observations within group id
Date   Mon, 2 Jun 2008 09:49:19 +0100

Answers interspersed below. 

Nick
[email protected] 

Chirantan Chatterjee

About the new in_EE or in_OECD variable which takes 1 or 0, i
essentially need a variable irrespective of Pub_nbr observations, that
is 1 for any EE inventor or OECD inventor observation - right? Why then
do i need the -merge- command, am i missing something here. 

>>> You don't need the -merge- approach, and I didn't say that you do,
but it is a good one. Why it is a good idea and how it works are
explained in detail in the two FAQs I directed you towards. 

About the code: 
bysort pub_nbr (in_OECD) : gen byte any_in_OECD = in_OECD[_N] == 1

Doesnt this generate a new variable, which takes 1, if all inventors in
pub_nbr, stacked one upon another are OECD inventors - whereas i need it
to be 1, even when i find just one inventor is from an OECD country. 

>>> No. The subscript [_N] ensures that you will get precisely what you
want. Even if there is only one such inventor, the observation for that
inventor will be last within each patent group, given the sort order, so
that it will still be true that -in_OECD[_N] == 1-. The command does
quite a lot at once. For a tutorial on -by:- see
<http://www.stata-journal.com/sjpdf.html?articlenum=pr0004>

SJ-2-1  pr0004  . . . . . . . . . . Speaking Stata:  How to move step
by: step
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q1/02   SJ 2(1):86--102                                  (no
commands)
        explains the use of the by varlist : construct to tackle
        a variety of problems with group structure, ranging from
        simple calculations for each of several groups to more
        advanced manipulations that use the built-in _n and _N

About the last variable, i need to do the same, even if one of the
patent applicant is from an OECD country - guess if you clarify the
above can figure that out for  myself.

>>> I trust so. 


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index