Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Counting without duplication

    Dear Statalist, I need your help for counting the number of others CITING family within a group of CITED family without duplicated obs. for a dataset of millions of obs. These counting need to fullfil three requirements:
    1. the CITING family must be different than the CITED family
    2. the CITING firms (citingcompany) of a given CITING family must to be different than the whole CITED firms group (citedcompany)
    3. the CITING firms (citingcompany) of a given CITING family must be different than the CITING firms of others CITING family in the same citing_year
    I believe that with an example it is easier to understand the idea of these two “count” variables that I need.

    Example: in the dataex below, the first CITING family (1037131) have two CITING firms (BERU and ELLER MARTIN), and none of them are in the “citedcompany” variable of the whole CITED family. Also, none of the two CITING firms are in the variable “citingcompany” of the other CITING family in the same year (2003). Therefore, the variable Count_t0 is 1 (there is only another CITING family with these conditions in the same citing_year). If any of the CITING firms (from this CITING family) are in the whole “citedcompany” (within the CITED family); or if any of these two CITING firms are in the list of CITING firms of the others CITING family (from the same year), then they will not count.

    Count_t1 do the same but for the next year. That is, none of the two CITING firms (BERU and ELLER MARTIN) are in the “citedcompany” variable for the group of CITED family. And also, these two firms are neither in the “citingcompany” variable of the other CITING families but in the next year (2004). Since there are two other CITING families in 2004 with these conditions, then Count_t1 is 2 (this is for the case of the first CITING family).

    For if it help, in the dataex you can see how these two "Count" variables must be.

    I am really struggling with this.
    Please, can you help me to build these two “Count” variables for this large dataset? It will be much appreciated!

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str36 citingcompany long(appln_nr pat_publn_id) str13 citing_publication str10 citing_pub_date int citing_year str19 citedcompany str10(cited_publication cited_pub_date) long(citing_family cited_family) byte(count_t0 count_t1)
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "GEISSINGER ALBRECHT" "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "GEISSINGER ALBRECHT" "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "LINDEMANN GERT"      "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "LINDEMANN GERT"      "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "KERN CHRISTOPH"      "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "KERN CHRISTOPH"      "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "OTTERBACH WOLFGANG"  "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "OTTERBACH WOLFGANG"  "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "HALUSCHKA CHRISTOPH" "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "HALUSCHKA CHRISTOPH" "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "REISSNER ANDREAS"    "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "REISSNER ANDREAS"    "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "LINDNER FRIEDERIKE"  "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "LINDNER FRIEDERIKE"  "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "ROBERT BOSCH"        "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "ROBERT BOSCH"        "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "BERU"                                 2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "DRESSLER WOLFGANG"   "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "ELLER MARTIN"                         2002221414 288391687 "JP2003145229A" "20/05/2003" 2003 "DRESSLER WOLFGANG"   "WO0116528"  "08/03/2001"  1037131 1000065 1 2
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "GEISSINGER ALBRECHT" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "GEISSINGER ALBRECHT" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "GEISSINGER ALBRECHT" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "GEISSINGER ALBRECHT" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "LINDEMANN GERT"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "LINDEMANN GERT"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "LINDEMANN GERT"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "LINDEMANN GERT"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "KERN CHRISTOPH"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "KERN CHRISTOPH"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "KERN CHRISTOPH"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "KERN CHRISTOPH"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "OTTERBACH WOLFGANG"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "OTTERBACH WOLFGANG"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "OTTERBACH WOLFGANG"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "OTTERBACH WOLFGANG"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "HALUSCHKA CHRISTOPH" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "HALUSCHKA CHRISTOPH" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "HALUSCHKA CHRISTOPH" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "HALUSCHKA CHRISTOPH" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "REISSNER ANDREAS"    "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "REISSNER ANDREAS"    "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "REISSNER ANDREAS"    "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "REISSNER ANDREAS"    "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "LINDNER FRIEDERIKE"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "LINDNER FRIEDERIKE"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "LINDNER FRIEDERIKE"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "LINDNER FRIEDERIKE"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "ROBERT BOSCH"        "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "ROBERT BOSCH"        "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "ROBERT BOSCH"        "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "ROBERT BOSCH"        "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                              204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "DRESSLER WOLFGANG"   "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                    204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "DRESSLER WOLFGANG"   "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                             204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "DRESSLER WOLFGANG"   "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                        204584 286548117 "WO03064346A1"  "07/08/2003" 2003 "DRESSLER WOLFGANG"   "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "BOSSERT JOERG"                          10228076 284740316 "DE10228076A1"  "08/01/2004" 2004 "GEISSINGER ALBRECHT" "WO0116529"  "08/03/2001" 13038647 1000065 1 0
    "FRIEDRICH-SCHILLER-UNIVERSITAET JENA"   10228076 284740316 "DE10228076A1"  "08/01/2004" 2004 "GEISSINGER ALBRECHT" "WO0116529"  "08/03/2001" 13038647 1000065 1 0
    "BOSSERT JOERG"                          10228076 284740316 "DE10228076A1"  "08/01/2004" 2004 "KERN CHRISTOPH"      "WO0116529"  "08/03/2001" 13038647 1000065 1 0
    "FRIEDRICH-SCHILLER-UNIVERSITAET JENA"   10228076 284740316 "DE10228076A1"  "08/01/2004" 2004 "KERN CHRISTOPH"      "WO0116529"  "08/03/2001" 13038647 1000065 1 0
    "BOSSERT JOERG"                          10228076 284740316 "DE10228076A1"  "08/01/2004" 2004 "SCHOTT STEFFEN"      "WO0116529"  "08/03/2001" 13038647 1000065 1 0
    "FRIEDRICH-SCHILLER-UNIVERSITAET JENA"   10228076 284740316 "DE10228076A1"  "08/01/2004" 2004 "SCHOTT STEFFEN"      "WO0116529"  "08/03/2001" 13038647 1000065 1 0
    "BOSSERT JOERG"                          10228076 284740316 "DE10228076A1"  "08/01/2004" 2004 "ROBERT BOSCH"        "WO0116529"  "08/03/2001" 13038647 1000065 1 0
    "FRIEDRICH-SCHILLER-UNIVERSITAET JENA"   10228076 284740316 "DE10228076A1"  "08/01/2004" 2004 "ROBERT BOSCH"        "WO0116529"  "08/03/2001" 13038647 1000065 1 0
    "BOSSERT JOERG"                          10228077 284740317 "DE10228077A1"  "08/01/2004" 2004 "GEISSINGER ALBRECHT" "DE10020328" "01/03/2001" 13038648 1000065 1 0
    "FRIEDRICH-SCHILLER-UNIVERSITAET JENA"   10228077 284740317 "DE10228077A1"  "08/01/2004" 2004 "GEISSINGER ALBRECHT" "DE10020328" "01/03/2001" 13038648 1000065 1 0
    "BOSSERT JOERG"                          10228077 284740317 "DE10228077A1"  "08/01/2004" 2004 "KERN CHRISTOPH"      "DE10020328" "01/03/2001" 13038648 1000065 1 0
    "FRIEDRICH-SCHILLER-UNIVERSITAET JENA"   10228077 284740317 "DE10228077A1"  "08/01/2004" 2004 "KERN CHRISTOPH"      "DE10020328" "01/03/2001" 13038648 1000065 1 0
    "BOSSERT JOERG"                          10228077 284740317 "DE10228077A1"  "08/01/2004" 2004 "SCHOTT STEFFEN"      "DE10020328" "01/03/2001" 13038648 1000065 1 0
    "FRIEDRICH-SCHILLER-UNIVERSITAET JENA"   10228077 284740317 "DE10228077A1"  "08/01/2004" 2004 "SCHOTT STEFFEN"      "DE10020328" "01/03/2001" 13038648 1000065 1 0
    "BOSSERT JOERG"                          10228077 284740317 "DE10228077A1"  "08/01/2004" 2004 "ROBERT BOSCH"        "DE10020328" "01/03/2001" 13038648 1000065 1 0
    "FRIEDRICH-SCHILLER-UNIVERSITAET JENA"   10228077 284740317 "DE10228077A1"  "08/01/2004" 2004 "ROBERT BOSCH"        "DE10020328" "01/03/2001" 13038648 1000065 1 0
    "DRESSLER WOLFGANG"                       2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "GEISSINGER ALBRECHT" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                   2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "GEISSINGER ALBRECHT" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                             2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "GEISSINGER ALBRECHT" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                            2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "GEISSINGER ALBRECHT" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                       2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "LINDEMANN GERT"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                   2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "LINDEMANN GERT"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                             2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "LINDEMANN GERT"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                            2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "LINDEMANN GERT"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                       2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "KERN CHRISTOPH"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                   2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "KERN CHRISTOPH"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                             2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "KERN CHRISTOPH"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                            2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "KERN CHRISTOPH"      "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                       2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "OTTERBACH WOLFGANG"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                   2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "OTTERBACH WOLFGANG"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                             2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "OTTERBACH WOLFGANG"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                            2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "OTTERBACH WOLFGANG"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                       2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "HALUSCHKA CHRISTOPH" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                   2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "HALUSCHKA CHRISTOPH" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                             2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "HALUSCHKA CHRISTOPH" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                            2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "HALUSCHKA CHRISTOPH" "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                       2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "REISSNER ANDREAS"    "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                   2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "REISSNER ANDREAS"    "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                             2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "REISSNER ANDREAS"    "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                            2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "REISSNER ANDREAS"    "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                       2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "LINDNER FRIEDERIKE"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                   2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "LINDNER FRIEDERIKE"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "RIEDEL RALF"                             2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "LINDNER FRIEDERIKE"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "ROBERT BOSCH"                            2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "LINDNER FRIEDERIKE"  "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "DRESSLER WOLFGANG"                       2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "ROBERT BOSCH"        "DE10020329" "22/03/2001"  9405455 1000065 0 0
    "KLONCZYNSKI ALEXANDER"                   2794999 286548118 "EP1472197A1"   "03/11/2004" 2004 "ROBERT BOSCH"        "DE10020329" "22/03/2001"  9405455 1000065 0 0
    end

  • #2
    Dear all, after analyzing and trying really hard the program that very kindly Clyde Schechter gave me as a starting point for this problem, I am unable to adapt it. I think I understand the idea behind. That is, the program creates a second dataset. And each time I want to count the rest of citing families within the same citing year, it merges both datasets eliminating from the second one the citing family for which I will count. Leaving only the rest of citing families (within cited family) in the same year.

    However, I do not know how to tell the program to keep only the other citing families (within cited family) in the same citing_year in which the “citingcompany” are different from the “citingcompany” of reference.

    Say I want to count how many other citing family (different from 1037131) also cites the same cited family in the same citing_year. That would be citing family = 9405455. However, does this other citing family serves as a count? NO, because some of its firms (ROBERT BOSCH, DRESSLER WOLFGANG) appear in the whole “citedcompany” (within cited family). The second rule is that these citing firms (from citing family=9405455) cannot appear as any of the “citingcompany” of the citing family of reference (that is, 1037131). If the citing firms from citing family=9405455 fulfill the two conditions, then citing family 9405455 will count as 1 for citing family 1037131 (which is not the case here because of the first condition).

    If I take now the citing family=9405455 as reference. I need to count the other citing family in its same citing_year (here would be citing family 1037131). As the citingcompany are not in the whole citedcompany (within cited family); and none of the citingcompany (in citing family 1037131) are in the citing family of reference (now citing family=9405455). Then, this one will count as 1 for citing family=9405455.

    If anyone could give a hand with this, it would be much appreciated.
    Ps. Notice that each citing family must count as 1 (even though there are several obs within the citing family).

    Code:
    capture program drop one_cited_appln_id_year
    program define one_cited_appln_id_year
        local comparators = source[1]
        joinby cited_family citing_year  using `comparators', unmatched(master)
        list obs_no cit* obs_no_U, noobs clean abbrev(12)    
        by obs_no citing_family_U, sort: keep if _n == 1   // REMOVE DUPLICATE CITING FAMILIES
        list obs_no cit* obs_no_U, noobs clean abbrev(12)
        by obs_no citingcompany_U, sort: keep if _n == 1   // REMOVE DUPLICATED CITING FRMS
        list obs_no cit* obs_no_U, noobs clean abbrev(12)
    
        by obs_no: egen wanted = total(obs_no_U != obs_no) // COUNT EVERYTHING BUT SELF_MATCH
        drop *_U
        by obs_no: keep if _n == 1
        drop obs_no _merge
        exit
    end
    
    gen long obs_no = _n
    preserve
    keep obs_no cited_family  citing_year  citing_family citingcompany
    sort cited_family citing_family  citing_year 
    rename (citing_family citingcompany obs_no) =_U
    tempfile comparators
    save `comparators'
    restore
    
    gen source = "`comparators'"
    runby one_cited_appln_id_year, by(obs_no) status
    drop source
    list, noobs clean abbrev(20)

    Comment

    Working...
    X