NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

520  /**********************************************/
521  /*Adding controls and cross sectional variables*/
522  /**********************************************/
523  Libname data '..\..\Data\Datasets';
NOTE: Libref DATA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets
524  Libname temp '..\..\Data\JAR\temp';
NOTE: Libref TEMP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp
525  
526  
527  proc sort data = data.compa78_20_20220410 out = comp nodupkey; by gvkey fyear; run;

NOTE: There were 404385 observations read from the data set DATA.COMPA78_20_20220410.
NOTE: 11 observations with duplicate key values were deleted.
NOTE: The data set WORK.COMP has 404374 observations and 63 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.27 seconds
      cpu time            0.26 seconds
      

528  data comp; set comp;
529   gvkey1 = input(gvkey, BEST12.);
530   drop gvkey;
531   rename gvkey1=gvkey; run;

NOTE: There were 404374 observations read from the data set WORK.COMP.
NOTE: The data set WORK.COMP has 404374 observations and 63 variables.
NOTE: DATA statement used (Total process time):
      real time           0.14 seconds
      cpu time            0.12 seconds
      

532  
533  data comp2; set comp;
534      if LT =. then LT =0;
535      if TXDB =. then TXDB =0;
536      if XRD =. then XRD =0;
537      if SPPE =. then SPPE=0;
538      if AQC =. then AQC =0;
539      if RECT =. then RECT =0;
540      if missing(dltt) then dltt=0;
541      if missing(dlc) then dlc=0;
542      MVE = CSHO*PRCC_F;
543  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      74611 at 542:15   
NOTE: There were 404374 observations read from the data set WORK.COMP.
NOTE: The data set WORK.COMP2 has 404374 observations and 64 variables.
NOTE: DATA statement used (Total process time):
      real time           0.15 seconds
      cpu time            0.14 seconds
      

544  
545  proc sort data = comp2; by gvkey fyear; run;

NOTE: There were 404374 observations read from the data set WORK.COMP2.
NOTE: The data set WORK.COMP2 has 404374 observations and 64 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.37 seconds
      cpu time            0.26 seconds
      

546  
547  data comp3; set comp2; by gvkey;
548      LSALE = ifn(first.gvkey, ., lag(SALE));
549      LAT = ifn(first.gvkey, ., lag(AT));
550      LLT = ifn(first.gvkey, ., lag(LT));
551      LMVE = ifn(first.gvkey, ., lag(MVE));
552      LDLC = ifn(first.gvkey, ., lag(DLC));
553      LDLTT = ifn(first.gvkey, ., lag(DLTT));
554      LTXDB = ifn(first.gvkey, ., lag(TXDB));
555      LCEQ = ifn(first.gvkey, ., lag(CEQ));
556  run;

NOTE: There were 404374 observations read from the data set WORK.COMP2.
NOTE: The data set WORK.COMP3 has 404374 observations and 72 variables.
NOTE: DATA statement used (Total process time):
      real time           0.19 seconds
      cpu time            0.17 seconds
      

557  
558  data comp4;
559      set comp3;
560      array NumVar AT;
561      do over NumVar;
562      if NumVar=. then AT = LAT;
563     end;
564  run;

NOTE: There were 404374 observations read from the data set WORK.COMP3.
NOTE: The data set WORK.COMP4 has 404374 observations and 72 variables.
NOTE: DATA statement used (Total process time):
      real time           0.41 seconds
      cpu time            0.15 seconds
      

565  
566  data comp4;
567      set comp4;
568      if LSALE =. then LSALE = SALE;
569      if SALE =. then SALE = LSALE;
570      if AT =. then delete;
571  run;

NOTE: There were 404374 observations read from the data set WORK.COMP4.
NOTE: The data set WORK.COMP4 has 341549 observations and 72 variables.
NOTE: DATA statement used (Total process time):
      real time           0.15 seconds
      cpu time            0.14 seconds
      

572  
573  data comp4;
574      set comp4;
575      if SALE =. then delete;
576  run;

NOTE: There were 341549 observations read from the data set WORK.COMP4.
NOTE: The data set WORK.COMP4 has 339657 observations and 72 variables.
NOTE: DATA statement used (Total process time):
      real time           0.14 seconds
      cpu time            0.14 seconds
      

577  
578  data comp5; set comp4;
579      roabeg = (IB+DP)/LAT;
580      rosalebeg = (IB+DP)/LSALE;
581      roaavg = 2*IB/(at+LAT);
582      xrd_at = xrd/at;
583      xrd_sale = xrd/sale;
584      xrd_ppent = xrd/ppent;
585      xrd_che = xrd/che;
586      LEV = (DLTT+DLC)/AT;
587      mtb = (MVE+LT)/AT;
588      loss = ni <0;
589      if ni=. then loss=.;
590      tangibility = PPENT/AT;
591      ch_sale = (SALE-LSALE)/LSALE;
592      CASH = (CHE)/at;
593  run;

NOTE: Division by zero detected at line 585 column 18.
datadate=19870630 fyear=1987 tic=2938B cusip=001032101 conm=AES TECHNOLOGY SYSTEMS INC curcd=USD
fyr=6 act=0.8060 aqc=0.0000 at=5.0210 capx=0.4490 ceq=-4.0360 ch=0.0000 che=0.0000 cogs=2.3080
cshi=. csho=6.5800 dlc=7.3340 dltt=0.3080 dp=0.2800 dvt=0.0000 emp=0.0580 ib=-0.8400 invt=0.3030
lct=8.7490 lt=9.0570 ni=-0.8400 oancf=. oibdp=0.2390 ppent=4.0440 rect=0.4730 sale=4.1310
sppe=1.8210 sppiv=. txdb=0.0000 xrd=0.2450 cik=0000002638 prcc_f=0.0620 endfyr=30JUN1987 year=1987
sic=3861 naics=333315 cyear=1987 date1=10013 endfyr1=30JUN1987 begfyr1=01JUL1986 sic1=3861 sic2=38
naics3=333 naics2=33 lag_endfyr=30JUN1986 linkprim=  liid=  linktype=  lpermno=. lpermco=.
USEDFLAG=. linkdt=. linkenddt=. SICCD=. sich=. sich2=. gvkey=1018 MVE=0.40796 LSALE=5.905 LAT=5.17
LLT=8.323 LMVE=1.2304598684 LDLC=0.398 LDLTT=7.175 LTXDB=0 LCEQ=-3.153 roabeg=-0.108317215
rosalebeg=-0.094834886 roaavg=-0.164851339 xrd_at=0.0487950607 xrd_sale=0.0593076737
xrd_ppent=0.0605835806 xrd_che=. LEV=1.5220075682 mtb=1.8850746863 loss=1 tangibility=0.8054172476
ch_sale=-0.30042337 CASH=0 _ERROR_=1 _N_=232
NOTE: Division by zero detected at line 585 column 18.
datadate=20011231 fyear=2001 tic=4267A cusip=001814003 conm=ANR PIPELINE CO curcd=USD fyr=12
act=405.0000 aqc=0.0000 at=1799.0000 capx=108.0000 ceq=696.0000 ch=0.0000 che=0.0000 cogs=691.0000
cshi=0.0010 csho=0.0010 dlc=0.0000 dltt=702.0000 dp=35.0000 dvt=30.0000 emp=0.3800 ib=-74.0000
invt=19.0000 lct=187.0000 lt=1103.0000 ni=-76.0000 oancf=166.0000 oibdp=-78.0000 ppent=1385.0000
rect=364.0000 sale=613.0000 sppe=0.0000 sppiv=-13.0000 txdb=134.0000 xrd=0.0000 cik=0000065695
prcc_f=. endfyr=31DEC2001 year=2001 sic=4922 naics=486210 cyear=2001 date1=15310 endfyr1=31DEC2001
begfyr1=01JAN2001 sic1=4922 sic2=49 naics3=486 naics2=48 lag_endfyr=31DEC2000 linkprim=  liid= 
linktype=  lpermno=. lpermco=. USEDFLAG=. linkdt=. linkenddt=. SICCD=. sich=. sich2=. gvkey=1048
MVE=. LSALE=592 LAT=1715 LLT=915 LMVE=. LDLC=0 LDLTT=498 LTXDB=230 LCEQ=800 roabeg=-0.022740525
rosalebeg=-0.065878378 roaavg=-0.042117245 xrd_at=0 xrd_sale=0 xrd_ppent=0 xrd_che=.
LEV=0.3902167871 mtb=. loss=1 tangibility=0.7698721512 ch_sale=0.035472973 CASH=0 _ERROR_=1 _N_=574
NOTE: Division by zero detected at line 585 column 18.
datadate=20021231 fyear=2002 tic=4267A cusip=001814003 conm=ANR PIPELINE CO curcd=USD fyr=12
act=88.0000 aqc=0.0000 at=1920.0000 capx=113.0000 ceq=817.0000 ch=0.0000 che=0.0000 cogs=287.0000
cshi=0.0010 csho=0.0010 dlc=0.0000 dltt=511.0000 dp=36.0000 dvt=0.0000 emp=0.3900 ib=120.0000
invt=23.0000 lct=159.0000 lt=1103.0000 ni=120.0000 oancf=165.0000 oibdp=257.0000 ppent=1407.0000
rect=57.0000 sale=544.0000 sppe=0.0000 sppiv=1.0000 txdb=185.0000 xrd=0.0000 cik=0000065695
prcc_f=. endfyr=31DEC2002 year=2002 sic=4922 naics=486210 cyear=2002 date1=15675 endfyr1=31DEC2002
begfyr1=01JAN2002 sic1=4922 sic2=49 naics3=486 naics2=48 lag_endfyr=31DEC2001 linkprim=  liid= 
linktype=  lpermno=. lpermco=. USEDFLAG=. linkdt=. linkenddt=. SICCD=. sich=. sich2=. gvkey=1048
MVE=. LSALE=613 LAT=1799 LLT=1103 LMVE=. LDLC=0 LDLTT=702 LTXDB=134 LCEQ=696 roabeg=0.0867148416
rosalebeg=0.2544861338 roaavg=0.0645334767 xrd_at=0 xrd_sale=0 xrd_ppent=0 xrd_che=.
LEV=0.2661458333 mtb=. loss=0 tangibility=0.7328125 ch_sale=-0.112561175 CASH=0 _ERROR_=1 _N_=575
NOTE: Division by zero detected at line 585 column 18.
datadate=20041231 fyear=2004 tic=4267A cusip=001814003 conm=ANR PIPELINE CO curcd=USD fyr=12
act=113.0000 aqc=0.0000 at=2472.0000 capx=143.0000 ceq=900.0000 ch=0.0000 che=0.0000 cogs=259.0000
cshi=0.0010 csho=0.0010 dlc=75.0000 dltt=733.0000 dp=37.0000 dvt=0.0000 emp=0.3900 ib=117.0000
invt=21.0000 lct=272.0000 lt=1572.0000 ni=117.0000 oancf=202.0000 oibdp=211.0000 ppent=1566.0000
rect=68.0000 sale=470.0000 sppe=0.0000 sppiv=2.0000 txdb=353.0000 xrd=0.0000 cik=0000065695
prcc_f=. endfyr=31DEC2004 year=2004 sic=4922 naics=486210 cyear=2004 date1=16406 endfyr1=31DEC2004
begfyr1=01JAN2004 sic1=4922 sic2=49 naics3=486 naics2=48 lag_endfyr=31DEC2003 linkprim=  liid= 
linktype=  lpermno=. lpermco=. USEDFLAG=. linkdt=. linkenddt=. SICCD=. sich=. sich2=. gvkey=1048
MVE=. LSALE=554 LAT=2307 LLT=1524 LMVE=. LDLC=0 LDLTT=807 LTXDB=307 LCEQ=783 roabeg=0.0667533593
rosalebeg=0.2779783394 roaavg=0.0489642185 xrd_at=0 xrd_sale=0 xrd_ppent=0 xrd_che=.
LEV=0.3268608414 mtb=. loss=0 tangibility=0.6334951456 ch_sale=-0.151624549 CASH=0 _ERROR_=1
_N_=577
NOTE: Division by zero detected at line 585 column 18.
datadate=20051231 fyear=2005 tic=4267A cusip=001814003 conm=ANR PIPELINE CO curcd=USD fyr=12
act=140.0000 aqc=0.0000 at=2617.0000 capx=125.0000 ceq=1047.0000 ch=0.0000 che=0.0000 cogs=291.0000
cshi=0.0010 csho=0.0010 dlc=0.0000 dltt=740.0000 dp=40.0000 dvt=0.0000 emp=0.3900 ib=148.0000
invt=21.0000 lct=234.0000 lt=1570.0000 ni=147.0000 oancf=253.0000 oibdp=257.0000 ppent=1631.0000
rect=101.0000 sale=548.0000 sppe=0.0000 sppiv=0.0000 txdb=370.0000 xrd=0.0000 cik=0000065695
prcc_f=. endfyr=31DEC2005 year=2005 sic=4922 naics=486210 cyear=2005 date1=16771 endfyr1=31DEC2005
begfyr1=01JAN2005 sic1=4922 sic2=49 naics3=486 naics2=48 lag_endfyr=31DEC2004 linkprim=  liid= 
linktype=  lpermno=. lpermco=. USEDFLAG=. linkdt=. linkenddt=. SICCD=. sich=. sich2=. gvkey=1048
MVE=. LSALE=470 LAT=2472 LLT=1572 LMVE=. LDLC=75 LDLTT=733 LTXDB=353 LCEQ=900 roabeg=0.0760517799
rosalebeg=0.4 roaavg=0.0581646689 xrd_at=0 xrd_sale=0 xrd_ppent=0 xrd_che=. LEV=0.2827665266 mtb=.
loss=0 tangibility=0.6232327092 ch_sale=0.1659574468 CASH=0 _ERROR_=1 _N_=578
NOTE: Division by zero detected at line 585 column 18.
datadate=20061231 fyear=2006 tic=4267A cusip=001814003 conm=ANR PIPELINE CO curcd=USD fyr=12
act=900.0000 aqc=0.0000 at=2749.0000 capx=168.0000 ceq=949.0000 ch=0.0000 che=0.0000 cogs=269.0000
cshi=0.0010 csho=0.0010 dlc=0.0000 dltt=741.0000 dp=37.0000 dvt=0.0000 emp=0.7700 ib=152.0000
invt=22.0000 lct=548.0000 lt=1800.0000 ni=152.0000 oancf=217.0000 oibdp=271.0000 ppent=1803.0000
rect=856.0000 sale=540.0000 sppe=0.0000 sppiv=0.0000 txdb=306.0000 xrd=0.0000 cik=0000065695
prcc_f=. endfyr=31DEC2006 year=2006 sic=4922 naics=486210 cyear=2006 date1=17136 endfyr1=31DEC2006
begfyr1=01JAN2006 sic1=4922 sic2=49 naics3=486 naics2=48 lag_endfyr=31DEC2005 linkprim=  liid= 
linktype=  lpermno=. lpermco=. USEDFLAG=. linkdt=. linkenddt=. SICCD=. sich=. sich2=. gvkey=1048
MVE=. LSALE=548 LAT=2617 LLT=1570 LMVE=. LDLC=0 LDLTT=740 LTXDB=370 LCEQ=1047 roabeg=0.0722200994
rosalebeg=0.3448905109 roaavg=0.0566530004 xrd_at=0 xrd_sale=0 xrd_ppent=0 xrd_che=.
LEV=0.2695525646 mtb=. loss=0 tangibility=0.6558748636 ch_sale=-0.01459854 CASH=0 _ERROR_=1 _N_=579
NOTE: Division by zero detected at line 583 column 19.
NOTE: Division by zero detected at line 585 column 18.
datadate=19880531 fyear=1987 tic=CECE cusip=125141101 conm=CECO ENVIRONMENTAL CORP curcd=USD fyr=5
act=0.0550 aqc=0.0000 at=1.0930 capx=0.0000 ceq=0.5720 ch=0.0000 che=0.0000 cogs=0.0000 cshi=.
csho=4.9280 dlc=0.0450 dltt=0.4650 dp=0.0000 dvt=0.0000 emp=0.0010 ib=-0.3250 invt=0.0000
lct=0.0560 lt=0.5210 ni=-0.3250 oancf=. oibdp=-0.0640 ppent=0.0240 rect=0.0000 sale=0.0000
sppe=0.0000 sppiv=0.0000 txdb=0.0000 xrd=0.0000 cik=0000003197 prcc_f=0.4370 endfyr=31MAY1988
year=1988 sic=3564 naics=333413 cyear=1988 date1=10348 endfyr1=31MAY1988 begfyr1=01JUN1987
sic1=3564 sic2=35 naics3=333 naics2=33 lag_endfyr=31MAY1987 linkprim=P liid=01 linktype=LC
lpermno=11499 lpermco=176 USEDFLAG=1 linkdt=19801128 linkenddt=E SICCD=3670 sich=3670 sich2=36
gvkey=1050 MVE=2.1535353594 LSALE=0.63 LAT=1.399 LLT=0.499 LMVE=5.543999655 LDLC=0 LDLTT=0.493
LTXDB=0 LCEQ=0.9 roabeg=-0.232308792 rosalebeg=-0.515873016 roaavg=-0.260834671 xrd_at=0 xrd_sale=.
xrd_ppent=0 xrd_che=. LEV=0.4666056725 mtb=2.4469673919 loss=1 tangibility=0.021957914 ch_sale=-1
CASH=0 _ERROR_=1 _N_=594
NOTE: Division by zero detected at line 580 column 24.
NOTE: Division by zero detected at line 583 column 19.
NOTE: Division by zero detected at line 591 column 27.
datadate=19890531 fyear=1988 tic=CECE cusip=125141101 conm=CECO ENVIRONMENTAL CORP curcd=USD fyr=5
act=0.3300 aqc=0.0000 at=1.4140 capx=0.0000 ceq=0.4870 ch=0.0000 che=0.3300 cogs=0.0000 cshi=.
csho=4.9280 dlc=0.0410 dltt=0.7040 dp=0.0080 dvt=0.0000 emp=0.0010 ib=-0.0820 invt=0.0000
lct=0.2230 lt=0.9270 ni=-0.0820 oancf=-0.0120 oibdp=-0.0630 ppent=0.0240 rect=0.0000 sale=0.0000
sppe=0.0000 sppiv=0.0030 txdb=0.0000 xrd=0.0000 cik=0000003197 prcc_f=0.4060 endfyr=31MAY1989
year=1989 sic=3564 naics=333413 cyear=1989 date1=10713 endfyr1=31MAY1989 begfyr1=01JUN1988
sic1=3564 sic2=35 naics3=333 naics2=33 lag_endfyr=31MAY1988 linkprim=P liid=01 linktype=LC
lpermno=11499 lpermco=176 USEDFLAG=1 linkdt=19801128 linkenddt=E SICCD=3670 sich=3670 sich2=36
gvkey=1050 MVE=2.0007676058 LSALE=0 LAT=1.093 LLT=0.521 LMVE=2.1535353594 LDLC=0.045 LDLTT=0.465
LTXDB=0 LCEQ=0.572 roabeg=-0.067703568 rosalebeg=. roaavg=-0.065416833 xrd_at=0 xrd_sale=.
xrd_ppent=0 xrd_che=0 LEV=0.526874116 mtb=2.0705570055 loss=1 tangibility=0.0169731259 ch_sale=.
CASH=0.2333804809 _ERROR_=1 _N_=595
NOTE: Division by zero detected at line 580 column 24.
NOTE: Division by zero detected at line 583 column 19.
NOTE: Division by zero detected at line 591 column 27.
datadate=19900531 fyear=1989 tic=CECE cusip=125141101 conm=CECO ENVIRONMENTAL CORP curcd=USD fyr=5
act=0.7580 aqc=0.0000 at=1.8420 capx=0.0000 ceq=0.2990 ch=0.0000 che=0.7570 cogs=0.0000 cshi=.
csho=4.9280 dlc=1.0400 dltt=0.2050 dp=0.0170 dvt=0.0000 emp=0.0010 ib=-0.1890 invt=0.0000
lct=1.3160 lt=1.5210 ni=-0.1890 oancf=-0.0210 oibdp=-0.2120 ppent=0.0240 rect=0.0000 sale=0.0000
sppe=0.0000 sppiv=-0.2050 txdb=0.0000 xrd=0.0000 cik=0000003197 prcc_f=0.2810 endfyr=31MAY1990
year=1990 sic=3564 naics=333413 cyear=1990 date1=11078 endfyr1=31MAY1990 begfyr1=01JUN1989
sic1=3564 sic2=35 naics3=333 naics2=33 lag_endfyr=31MAY1989 linkprim=P liid=01 linktype=LC
lpermno=11499 lpermco=176 USEDFLAG=1 linkdt=19801128 linkenddt=E SICCD=3670 sich=3670 sich2=36
gvkey=1050 MVE=1.384767655 LSALE=0 LAT=1.414 LLT=0.927 LMVE=2.0007676058 LDLC=0.041 LDLTT=0.704
LTXDB=0 LCEQ=0.487 roabeg=-0.121640736 rosalebeg=. roaavg=-0.116093366 xrd_at=0 xrd_sale=.
xrd_ppent=0 xrd_che=0 LEV=0.6758957655 mtb=1.5775068703 loss=1 tangibility=0.013029316 ch_sale=.
CASH=0.4109663409 _ERROR_=1 _N_=596
NOTE: Division by zero detected at line 580 column 24.
NOTE: Division by zero detected at line 583 column 19.
NOTE: Division by zero detected at line 585 column 18.
NOTE: Division by zero detected at line 591 column 27.
datadate=19910531 fyear=1990 tic=CECE cusip=125141101 conm=CECO ENVIRONMENTAL CORP curcd=USD fyr=5
act=0.0040 aqc=0.0000 at=0.1260 capx=0.0000 ceq=-0.7780 ch=0.0000 che=0.0000 cogs=0.0000 cshi=.
csho=9.9280 dlc=0.6240 dltt=0.2260 dp=0.0000 dvt=0.0000 emp=0.0000 ib=-1.1720 invt=0.0000
lct=0.6780 lt=0.9040 ni=-1.6100 oancf=-0.0110 oibdp=-0.0320 ppent=0.0240 rect=0.0000 sale=0.0000
sppe=0.0000 sppiv=0.0000 txdb=0.0000 xrd=0.0000 cik=0000003197 prcc_f=0.5000 endfyr=31MAY1991
year=1991 sic=3564 naics=333413 cyear=1991 date1=11443 endfyr1=31MAY1991 begfyr1=01JUN1990
sic1=3564 sic2=35 naics3=333 naics2=33 lag_endfyr=31MAY1990 linkprim=P liid=01 linktype=LC
lpermno=11499 lpermco=176 USEDFLAG=1 linkdt=19801128 linkenddt=E SICCD=3670 sich=3670 sich2=36
gvkey=1050 MVE=4.9639997022 LSALE=0 LAT=1.842 LLT=1.521 LMVE=1.384767655 LDLC=1.04 LDLTT=0.205
LTXDB=0 LCEQ=0.299 roabeg=-0.636264929 rosalebeg=. roaavg=-1.191056911 xrd_at=0 xrd_sale=.
xrd_ppent=0 xrd_che=. LEV=6.746031746 mtb=46.571426208 loss=1 tangibility=0.1904761905 ch_sale=.
CASH=0 _ERROR_=1 _N_=597
NOTE: Division by zero detected at line 580 column 24.
NOTE: Division by zero detected at line 583 column 19.
NOTE: Division by zero detected at line 591 column 27.
datadate=19920531 fyear=1991 tic=CECE cusip=125141101 conm=CECO ENVIRONMENTAL CORP curcd=USD fyr=5
act=0.0780 aqc=0.0000 at=5.2000 capx=0.0000 ceq=4.0740 ch=0.0010 che=0.0260 cogs=0.0040 cshi=.
csho=18.5110 dlc=0.8260 dltt=0.2240 dp=0.0000 dvt=0.0000 emp=0.0000 ib=-0.2180 invt=0.0000
lct=0.9020 lt=1.1260 ni=-0.2180 oancf=-0.0990 oibdp=-0.0690 ppent=0.0240 rect=0.0500 sale=0.0000
sppe=0.0000 sppiv=-0.0050 txdb=0.0000 xrd=0.0000 cik=0000003197 prcc_f=0.6560 endfyr=31MAY1992
year=1992 sic=3564 naics=333413 cyear=1992 date1=11809 endfyr1=31MAY1992 begfyr1=01JUN1991
sic1=3564 sic2=35 naics3=333 naics2=33 lag_endfyr=31MAY1991 linkprim=P liid=01 linktype=LC
lpermno=11499 lpermco=176 USEDFLAG=1 linkdt=19801128 linkenddt=E SICCD=3670 sich=3670 sich2=36
gvkey=1050 MVE=12.143214334 LSALE=0 LAT=0.126 LLT=0.904 LMVE=4.9639997022 LDLC=0.624 LDLTT=0.226
LTXDB=0 LCEQ=-0.778 roabeg=-1.73015873 rosalebeg=. roaavg=-0.081862561 xrd_at=0 xrd_sale=.
xrd_ppent=0 xrd_che=0 LEV=0.2019230769 mtb=2.5517719873 loss=1 tangibility=0.0046153846 ch_sale=.
CASH=0.005 _ERROR_=1 _N_=598
NOTE: Division by zero detected at line 580 column 24.
NOTE: Division by zero detected at line 583 column 19.
NOTE: Division by zero detected at line 591 column 27.
datadate=19921231 fyear=1992 tic=CECE cusip=125141101 conm=CECO ENVIRONMENTAL CORP curcd=USD fyr=12
act=0.0010 aqc=0.0000 at=0.1330 capx=. ceq=-0.7920 ch=0.0010 che=0.0010 cogs=0.0030 cshi=.
csho=3.5740 dlc=0.9030 dltt=0.0000 dp=0.0000 dvt=0.0000 emp=0.0000 ib=-0.0740 invt=0.0000
lct=0.9250 lt=0.9250 ni=-0.0740 oancf=. oibdp=-0.0480 ppent=0.0240 rect=0.0000 sale=0.0000
sppe=0.0000 sppiv=. txdb=0.0000 xrd=0.0000 cik=0000003197 prcc_f=3.0310 endfyr=31DEC1992 year=1992
sic=3564 naics=333413 cyear=1992 date1=12023 endfyr1=31DEC1992 begfyr1=01JAN1992 sic1=3564 sic2=35
naics3=333 naics2=33 lag_endfyr=31MAY1992 linkprim=P liid=01 linktype=LC lpermno=11499 lpermco=176
USEDFLAG=1 linkdt=19801128 linkenddt=E SICCD=3670 sich=3670 sich2=36 gvkey=1050 MVE=10.832791069
LSALE=0 LAT=5.2 LLT=1.126 LMVE=12.143214334 LDLC=0.826 LDLTT=0.224 LTXDB=0 LCEQ=4.074
roabeg=-0.014230769 rosalebeg=. roaavg=-0.027751734 xrd_at=0 xrd_sale=. xrd_ppent=0 xrd_che=0
LEV=6.7894736842 mtb=88.40444413 loss=1 tangibility=0.1804511278 ch_sale=. CASH=0.007518797
_ERROR_=1 _N_=599
NOTE: Division by zero detected at line 580 column 24.
NOTE: Division by zero detected at line 591 column 27.
datadate=19931231 fyear=1993 tic=CECE cusip=125141101 conm=CECO ENVIRONMENTAL CORP curcd=USD fyr=12
act=3.1640 aqc=-0.0690 at=8.0470 capx=0.1180 ceq=2.5120 ch=0.0230 che=0.0230 cogs=4.2000 cshi=.
csho=5.8170 dlc=1.5600 dltt=2.1490 dp=0.2770 dvt=0.0000 emp=0.0490 ib=-0.3160 invt=0.3660
lct=2.6580 lt=4.8720 ni=-0.3160 oancf=-1.2300 oibdp=-0.0040 ppent=2.2680 rect=2.6370 sale=6.9140
sppe=0.0000 sppiv=0.0000 txdb=0.0650 xrd=0.0560 cik=0000003197 prcc_f=3.1870 endfyr=31DEC1993
year=1993 sic=3564 naics=333413 cyear=1993 date1=12388 endfyr1=31DEC1993 begfyr1=01JAN1993
sic1=3564 sic2=35 naics3=333 naics2=33 lag_endfyr=31DEC1992 linkprim=P liid=01 linktype=LC
lpermno=11499 lpermco=176 USEDFLAG=1 linkdt=19801128 linkenddt=E SICCD=3670 sich=3670 sich2=36
gvkey=1050 MVE=18.538775044 LSALE=0 LAT=0.133 LLT=0.925 LMVE=10.832791069 LDLC=0.903 LDLTT=0
LTXDB=0 LCEQ=-0.792 roabeg=-0.293233083 rosalebeg=. roaavg=-0.077261614 xrd_at=0.0069591152
xrd_sale=0.0080995082 xrd_ppent=0.024691358 xrd_che=2.4347826087 LEV=0.460917112 mtb=2.9092550074
loss=1 tangibility=0.2818441655 ch_sale=. CASH=0.002858208 _ERROR_=1 _N_=600
NOTE: Division by zero detected at line 584 column 20.
datadate=19780331 fyear=1977 tic=APITS cusip=001864107 conm=API TRUST curcd=USD fyr=3 act=.
aqc=0.0000 at=44.8980 capx=0.0000 ceq=7.0630 ch=0.1780 che=1.7490 cogs=2.0240 cshi=. csho=1.0120
dlc=10.3780 dltt=26.3490 dp=0.0000 dvt=0.1010 emp=. ib=-1.0790 invt=0.0000 lct=11.4860 lt=37.8350
ni=-1.0790 oancf=. oibdp=2.5940 ppent=0.0000 rect=0.0000 sale=4.6180 sppe=0.0000 sppiv=.
txdb=0.0000 xrd=0.0000 cik=0000006839 prcc_f=. endfyr=31MAR1978 year=1978 sic=6798 naics= 
cyear=1978 date1=6634 endfyr1=31MAR1978 begfyr1=01APR1977 sic1=6798 sic2=67 naics3=. naics2=.
lag_endfyr=. linkprim=C liid=00X linktype=LU lpermno=10402 lpermco=311 USEDFLAG=1 linkdt=19730401
linkenddt=19790130 SICCD=6799 sich=6799 sich2=67 gvkey=1052 MVE=. LSALE=4.618 LAT=. LLT=. LMVE=.
LDLC=. LDLTT=. LTXDB=. LCEQ=. roabeg=. rosalebeg=-0.233650931 roaavg=. xrd_at=0 xrd_sale=0
xrd_ppent=. xrd_che=0 LEV=0.8180097109 mtb=. loss=1 tangibility=0 ch_sale=0 CASH=0.0389549646
_ERROR_=1 _N_=628
NOTE: Division by zero detected at line 584 column 20.
datadate=19790331 fyear=1978 tic=APITS cusip=001864107 conm=API TRUST curcd=USD fyr=3 act=.
aqc=0.0000 at=33.1520 capx=0.0000 ceq=7.8400 ch=0.6210 che=0.6210 cogs=1.1620 cshi=. csho=1.0120
dlc=13.4040 dltt=10.2960 dp=0.0000 dvt=0.0000 emp=. ib=0.7770 invt=0.0000 lct=15.0160 lt=25.3120
ni=0.7770 oancf=. oibdp=3.1510 ppent=0.0000 rect=0.0000 sale=4.3130 sppe=0.0000 sppiv=. txdb=0.0000
xrd=0.0000 cik=0000006839 prcc_f=2.2500 endfyr=31MAR1979 year=1979 sic=6798 naics=  cyear=1979
date1=6999 endfyr1=31MAR1979 begfyr1=01APR1978 sic1=6798 sic2=67 naics3=. naics2=.
lag_endfyr=31MAR1978 linkprim=  liid=  linktype=  lpermno=. lpermco=. USEDFLAG=. linkdt=.
linkenddt=. SICCD=. sich=. sich2=. gvkey=1052 MVE=2.277 LSALE=4.618 LAT=44.898 LLT=37.835 LMVE=.
LDLC=10.378 LDLTT=26.349 LTXDB=0 LCEQ=7.063 roabeg=0.0173058934 rosalebeg=0.1682546557
roaavg=0.0199103139 xrd_at=0 xrd_sale=0 xrd_ppent=. xrd_che=0 LEV=0.7148889961 mtb=0.8321971525
loss=0 tangibility=0 ch_sale=-0.066045907 CASH=0.0187319015 _ERROR_=1 _N_=629
NOTE: Division by zero detected at line 584 column 20.
datadate=19800331 fyear=1979 tic=APITS cusip=001864107 conm=API TRUST curcd=USD fyr=3 act=.
aqc=0.0000 at=27.6220 capx=0.0000 ceq=7.9850 ch=0.0620 che=0.5520 cogs=0.9510 cshi=. csho=1.0120
dlc=3.2550 dltt=15.4860 dp=0.0000 dvt=0.0000 emp=. ib=0.1450 invt=0.0000 lct=4.1510 lt=19.6370
ni=0.1450 oancf=. oibdp=2.0240 ppent=0.0000 rect=0.0000 sale=2.9750 sppe=0.0000 sppiv=. txdb=0.0000
xrd=0.0000 cik=0000006839 prcc_f=2.5000 endfyr=31MAR1980 year=1980 sic=6798 naics=  cyear=1980
date1=7365 endfyr1=31MAR1980 begfyr1=01APR1979 sic1=6798 sic2=67 naics3=. naics2=.
lag_endfyr=31MAR1979 linkprim=P liid=01 linktype=LU lpermno=10402 lpermco=311 USEDFLAG=1
linkdt=19790131 linkenddt=19830331 SICCD=6799 sich=6799 sich2=67 gvkey=1052 MVE=2.53 LSALE=4.313
LAT=33.152 LLT=25.312 LMVE=2.277 LDLC=13.404 LDLTT=10.296 LTXDB=0 LCEQ=7.84 roabeg=0.0043737934
rosalebeg=0.0336192905 roaavg=0.0047717774 xrd_at=0 xrd_sale=0 xrd_ppent=. xrd_che=0
LEV=0.678480921 mtb=0.80251249 loss=0 tangibility=0 ch_sale=-0.310224901 CASH=0.0199840707
_ERROR_=1 _N_=630
NOTE: Division by zero detected at line 584 column 20.
datadate=19810331 fyear=1980 tic=APITS cusip=001864107 conm=API TRUST curcd=USD fyr=3 act=.
aqc=0.0000 at=22.5640 capx=0.0000 ceq=6.8740 ch=0.2190 che=0.2190 cogs=3.3200 cshi=. csho=1.0120
dlc=4.5880 dltt=10.3160 dp=0.0000 dvt=0.0000 emp=. ib=-2.8110 invt=0.0000 lct=5.3740 lt=15.6900
ni=-2.8110 oancf=. oibdp=-0.6710 ppent=0.0000 rect=0.0000 sale=2.6490 sppe=0.0000 sppiv=.
txdb=0.0000 xrd=0.0000 cik=0000006839 prcc_f=3.3750 endfyr=31MAR1981 year=1981 sic=6798 naics= 
cyear=1981 date1=7730 endfyr1=31MAR1981 begfyr1=01APR1980 sic1=6798 sic2=67 naics3=. naics2=.
lag_endfyr=31MAR1980 linkprim=P liid=01 linktype=LU lpermno=10402 lpermco=311 USEDFLAG=1
linkdt=19790131 linkenddt=19830331 SICCD=6799 sich=6799 sich2=67 gvkey=1052 MVE=3.4155 LSALE=2.975
LAT=27.622 LLT=19.637 LMVE=2.53 LDLC=3.255 LDLTT=15.486 LTXDB=0 LCEQ=7.985 roabeg=-0.101766708
rosalebeg=-0.94487395 roaavg=-0.112023273 xrd_at=0 xrd_sale=0 xrd_ppent=. xrd_che=0
LEV=0.6605211842 mtb=0.8467248715 loss=1 tangibility=0 ch_sale=-0.109579832 CASH=0.0097057259
_ERROR_=1 _N_=631
NOTE: Division by zero detected at line 584 column 20.
datadate=19820331 fyear=1981 tic=APITS cusip=001864107 conm=API TRUST curcd=USD fyr=3 act=.
aqc=0.0000 at=22.0370 capx=0.0000 ceq=7.0130 ch=0.3800 che=0.3800 cogs=0.8280 cshi=. csho=1.3900
dlc=1.1970 dltt=12.9380 dp=0.0000 dvt=0.0000 emp=0.0000 ib=0.0940 invt=0.0000 lct=2.0860 lt=15.0240
ni=0.1390 oancf=. oibdp=1.6710 ppent=0.0000 rect=0.0000 sale=2.4990 sppe=0.0000 sppiv=. txdb=0.0000
xrd=0.0000 cik=0000006839 prcc_f=2.5000 endfyr=31MAR1982 year=1982 sic=6798 naics=  cyear=1982
date1=8095 endfyr1=31MAR1982 begfyr1=01APR1981 sic1=6798 sic2=67 naics3=. naics2=.
lag_endfyr=31MAR1981 linkprim=P liid=01 linktype=LU lpermno=10402 lpermco=311 USEDFLAG=1
linkdt=19790131 linkenddt=19830331 SICCD=6799 sich=6799 sich2=67 gvkey=1052 MVE=3.475 LSALE=2.649
LAT=22.564 LLT=15.69 LMVE=3.4155 LDLC=4.588 LDLTT=10.316 LTXDB=0 LCEQ=6.874 roabeg=0.004165928
rosalebeg=0.0354850887 roaavg=0.0042151521 xrd_at=0 xrd_sale=0 xrd_ppent=. xrd_che=0
LEV=0.6414212461 mtb=0.839451831 loss=0 tangibility=0 ch_sale=-0.056625142 CASH=0.0172437265
_ERROR_=1 _N_=632
NOTE: Division by zero detected at line 584 column 20.
datadate=19781130 fyear=1978 tic=ASA cusip=G3156P103 conm=ASA GOLD AND PRECIOUS METALS curcd=USD
fyr=11 act=. aqc=0.0000 at=205.0940 capx=. ceq=203.7930 ch=2.5320 che=6.3320 cogs=0.8420 cshi=.
csho=9.6000 dlc=0.0000 dltt=0.0000 dp=0.0000 dvt=9.6000 emp=. ib=13.1020 invt=0.0000 lct=.
lt=1.3010 ni=13.1020 oancf=. oibdp=12.8540 ppent=0.0000 rect=0.0000 sale=13.6960 sppe=0.0000
sppiv=. txdb=0.0000 xrd=0.0000 cik=0001230869 prcc_f=22.0000 endfyr=30NOV1978 year=1978 sic=6799
naics=523999 cyear=1978 date1=6879 endfyr1=30NOV1978 begfyr1=01DEC1977 sic1=6799 sic2=67 naics3=523
naics2=52 lag_endfyr=. linkprim=P liid=01 linktype=LU lpermno=26649 lpermco=20015 USEDFLAG=1
linkdt=19650129 linkenddt=E SICCD=6723 sich=6723 sich2=67 gvkey=1062 MVE=211.2 LSALE=13.696 LAT=.
LLT=. LMVE=. LDLC=. LDLTT=. LTXDB=. LCEQ=. roabeg=. rosalebeg=0.9566296729 roaavg=. xrd_at=0
xrd_sale=0 xrd_ppent=. xrd_che=0 LEV=0 mtb=1.0361151472 loss=0 tangibility=0 ch_sale=0
CASH=0.0308736482 _ERROR_=1 _N_=712
NOTE: Division by zero detected at line 584 column 20.
WARNING: Limit set by ERRORS= option reached.  Further errors of this type will not be printed.
datadate=19791130 fyear=1979 tic=ASA cusip=G3156P103 conm=ASA GOLD AND PRECIOUS METALS curcd=USD
fyr=11 act=. aqc=0.0000 at=408.4310 capx=. ceq=405.7830 ch=5.4600 che=5.4600 cogs=0.9520 cshi=.
csho=9.6000 dlc=0.0000 dltt=0.0000 dp=0.0000 dvt=23.0400 emp=. ib=24.1430 invt=0.0000 lct=2.5370
lt=2.6480 ni=24.1430 oancf=. oibdp=23.8570 ppent=0.0000 rect=0.0000 sale=24.8090 sppe=0.0000
sppiv=. txdb=0.0000 xrd=0.0000 cik=0001230869 prcc_f=31.2500 endfyr=30NOV1979 year=1979 sic=6799
naics=523999 cyear=1979 date1=7244 endfyr1=30NOV1979 begfyr1=01DEC1978 sic1=6799 sic2=67 naics3=523
naics2=52 lag_endfyr=30NOV1978 linkprim=P liid=01 linktype=LU lpermno=26649 lpermco=20015
USEDFLAG=1 linkdt=19650129 linkenddt=E SICCD=6723 sich=6723 sich2=67 gvkey=1062 MVE=300
LSALE=13.696 LAT=205.094 LLT=1.301 LMVE=211.2 LDLC=0 LDLTT=0 LTXDB=0 LCEQ=203.793
roabeg=0.1177167543 rosalebeg=1.7627774533 roaavg=0.0787025794 xrd_at=0 xrd_sale=0 xrd_ppent=.
xrd_che=0 LEV=0 mtb=0.74100154 loss=0 tangibility=0 ch_sale=0.8114047897 CASH=0.0133682311
_ERROR_=1 _N_=713
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      14371 at 579:17   28740 at 579:21   14371 at 580:20   1413 at 581:15    29682 at 581:22
      7918 at 584:20    1282 at 585:18    54336 at 587:15   7918 at 590:24    1282 at 592:17
NOTE: Mathematical operations could not be performed at the following places. The results of the 
      operations have been set to missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      875 at 579:21     14640 at 580:24   435 at 581:18     1042 at 582:17    14265 at 583:19
      14051 at 584:20   5602 at 585:18    1042 at 586:21    798 at 587:19     1029 at 590:24
      14859 at 591:27   1029 at 592:17    
NOTE: There were 339657 observations read from the data set WORK.COMP4.
NOTE: The data set WORK.COMP5 has 339657 observations and 85 variables.
NOTE: DATA statement used (Total process time):
      real time           0.33 seconds
      cpu time            0.35 seconds
      

594  
595  proc sort data = comp5; by gvkey fyear; run;

NOTE: There were 339657 observations read from the data set WORK.COMP5.
NOTE: The data set WORK.COMP5 has 339657 observations and 85 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.35 seconds
      cpu time            0.42 seconds
      

596  
597  data comp5; set comp5;
598      if sich2=. then sich2 = sic2;
599      if siccd=. then siccd = sic1;
600  run;

NOTE: There were 339657 observations read from the data set WORK.COMP5.
NOTE: The data set WORK.COMP5 has 339657 observations and 85 variables.
NOTE: DATA statement used (Total process time):
      real time           0.17 seconds
      cpu time            0.20 seconds
      

601  
602  proc sql;
603      create table comp5 as
604      select *,  sum(SALE) as Industry_sale
605      from comp5
606      group by sich2, fyear;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.COMP5 created, with 339657 rows and 86 columns.

607  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.58 seconds
      cpu time            0.70 seconds
      

608  
609  data comp5; set comp5;
610      market_share = (SALE/Industry_sale);
611  run;

NOTE: Division by zero detected at line 610 column 25.
datadate=20111231 fyear=2011 tic=ARWD cusip=04276R109 conm=ARROW RESOURCES DEVLPMT INC curcd=USD
fyr=12 act=0.0000 aqc=0.0000 at=0.0000 capx=0.0000 ceq=-32.5880 ch=0.0000 che=0.0000 cogs=0.0000
cshi=737.3690 csho=737.3690 dlc=2.5610 dltt=0.0000 dp=0.0000 dvt=0.0000 emp=. ib=-8.8170
invt=0.0000 lct=32.5880 lt=32.5880 ni=-8.8170 oancf=-3.7930 oibdp=-5.5730 ppent=0.0000 rect=0.0000
sale=0.0000 sppe=0.0000 sppiv=0.0000 txdb=0.0000 xrd=0.0000 cik=0000795255 prcc_f=0.0160
endfyr=31DEC2011 year=2011 sic=0800 naics=113210 cyear=2011 date1=18962 endfyr1=31DEC2011
begfyr1=01JAN2011 sic1=800 sic2=8 naics3=113 naics2=11 lag_endfyr=31DEC2010 linkprim=  liid= 
linktype=  lpermno=. lpermco=. USEDFLAG=. linkdt=. linkenddt=. SICCD=800 sich=. sich2=8 gvkey=12466
MVE=11.797904 LSALE=0 LAT=0 LLT=25.353 LMVE=45.82188 LDLC=2.136 LDLTT=0 LTXDB=0 LCEQ=-25.353
roabeg=. rosalebeg=. roaavg=. xrd_at=. xrd_sale=. xrd_ppent=. xrd_che=. LEV=. mtb=. loss=1
tangibility=. ch_sale=. CASH=. Industry_sale=0 market_share=. _ERROR_=1 _N_=3986
NOTE: Division by zero detected at line 610 column 25.
datadate=20121231 fyear=2012 tic=ARWD cusip=04276R109 conm=ARROW RESOURCES DEVLPMT INC curcd=USD
fyr=12 act=0.0000 aqc=0.0000 at=0.0000 capx=0.0000 ceq=-41.2010 ch=0.0000 che=0.0000 cogs=0.0000
cshi=767.5400 csho=767.5400 dlc=2.6160 dltt=0.0000 dp=0.0000 dvt=0.0000 emp=. ib=-8.6280
invt=0.0000 lct=41.2010 lt=41.2010 ni=-8.6280 oancf=-4.7010 oibdp=-6.4540 ppent=0.0000 rect=0.0000
sale=0.0000 sppe=0.0000 sppiv=0.0000 txdb=0.0000 xrd=0.0000 cik=0000795255 prcc_f=0.0150
endfyr=31DEC2012 year=2012 sic=0800 naics=113210 cyear=2012 date1=19328 endfyr1=31DEC2012
begfyr1=01JAN2012 sic1=800 sic2=8 naics3=113 naics2=11 lag_endfyr=31DEC2011 linkprim=  liid= 
linktype=  lpermno=. lpermco=. USEDFLAG=. linkdt=. linkenddt=. SICCD=800 sich=. sich2=8 gvkey=12466
MVE=11.5131 LSALE=0 LAT=0 LLT=32.588 LMVE=11.797904 LDLC=2.561 LDLTT=0 LTXDB=0 LCEQ=-32.588
roabeg=. rosalebeg=. roaavg=. xrd_at=. xrd_sale=. xrd_ppent=. xrd_che=. LEV=. mtb=. loss=1
tangibility=. ch_sale=. CASH=. Industry_sale=0 market_share=. _ERROR_=1 _N_=3987
NOTE: Division by zero detected at line 610 column 25.
datadate=19971031 fyear=1997 tic=LVEN. cusip=517669305 conm=LAS VEGAS ENTERTAINMNT NTWK curcd=USD
fyr=10 act=3.4870 aqc=0.0000 at=9.7710 capx=0.0440 ceq=7.5420 ch=2.3990 che=3.4870 cogs=4.9770
cshi=. csho=34.8980 dlc=0.7760 dltt=0.0000 dp=0.2540 dvt=0.0000 emp=. ib=-6.7520 invt=0.0000
lct=1.8650 lt=2.2280 ni=-6.7520 oancf=-4.4610 oibdp=-4.9770 ppent=0.1420 rect=0.0000 sale=0.0000
sppe=0.0000 sppiv=-0.0880 txdb=0.0000 xrd=1.0310 cik=0000872588 prcc_f=0.2340 endfyr=31OCT1997
year=1997 sic=8741 naics=561110 cyear=1997 date1=13788 endfyr1=31OCT1997 begfyr1=01NOV1996
sic1=8741 sic2=87 naics3=561 naics2=56 lag_endfyr=31OCT1996 linkprim=P liid=01 linktype=LU
lpermno=77351 lpermco=11355 USEDFLAG=1 linkdt=19920220 linkenddt=19991029 SICCD=7110 sich=7110
sich2=71 gvkey=24958 MVE=8.1661309531 LSALE=0.291 LAT=18.478 LLT=1.949 LMVE=14.168586604 LDLC=1.056
LDLTT=0 LTXDB=0 LCEQ=16.529 roabeg=-0.351661435 rosalebeg=-22.32989691 roaavg=-0.478034621
xrd_at=0.1055163238 xrd_sale=. xrd_ppent=7.2605633803 xrd_che=0.2956696301 LEV=0.079418688
mtb=1.0637735087 loss=1 tangibility=0.0145328011 ch_sale=-1 CASH=0.3568723774 Industry_sale=0
market_share=. _ERROR_=1 _N_=278786
NOTE: Division by zero detected at line 610 column 25.
datadate=19981231 fyear=1998 tic=CNDO.1 cusip=225637107 conm=CRESCENDO PHARM CORP  -CL A curcd=USD
fyr=12 act=114.2240 aqc=0.0000 at=193.9110 capx=0.0000 ceq=176.2380 ch=54.3260 che=111.7360
cogs=0.0000 cshi=4.9660 csho=4.9660 dlc=0.0000 dltt=0.0000 dp=0.0000 dvt=0.0000 emp=0.0010
ib=-95.7950 invt=0.0000 lct=17.6730 lt=17.6730 ni=-95.7950 oancf=-94.6410 oibdp=-107.2820
ppent=0.0000 rect=1.8610 sale=0.0000 sppe=0.0000 sppiv=0.0000 txdb=0.0000 xrd=105.9660
cik=0001042138 prcc_f=13.6250 endfyr=31DEC1998 year=1998 sic=2836 naics=325414 cyear=1998
date1=14214 endfyr1=31DEC1998 begfyr1=01JAN1998 sic1=2836 sic2=28 naics3=325 naics2=32
lag_endfyr=31DEC1997 linkprim=P liid=01 linktype=LU lpermno=85461 lpermco=15733 USEDFLAG=1
linkdt=19971001 linkenddt=20001130 SICCD=8520 sich=8520 sich2=85 gvkey=65420 MVE=67.66175 LSALE=0
LAT=286.587 LLT=15.108 LMVE=57.416888623 LDLC=0 LDLTT=0 LTXDB=0 LCEQ=271.479 roabeg=-0.334261498
rosalebeg=. roaavg=-0.398732149 xrd_at=0.5464671937 xrd_sale=. xrd_ppent=. xrd_che=0.948360421
LEV=0 mtb=0.4400717339 loss=1 tangibility=0 ch_sale=. CASH=0.5762231127 Industry_sale=0
market_share=. _ERROR_=1 _N_=323483
NOTE: Mathematical operations could not be performed at the following places. The results of the 
      operations have been set to missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      4 at 610:25   
NOTE: There were 339657 observations read from the data set WORK.COMP5.
NOTE: The data set WORK.COMP5 has 339657 observations and 87 variables.
NOTE: DATA statement used (Total process time):
      real time           0.16 seconds
      cpu time            0.15 seconds
      

612  
613  proc sql;
614      create table comp5 as
615      select *,  sum(market_share*market_share) as sum_market_share
616      from comp5
617      group by sich2, fyear;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.COMP5 created, with 339657 rows and 88 columns.

618  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.78 seconds
      cpu time            0.71 seconds
      

619  
620  data comp5; set comp5;
621      hi = log(sum_market_share+1);
622  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      4 at 621:10   4 at 621:30   
NOTE: There were 339657 observations read from the data set WORK.COMP5.
NOTE: The data set WORK.COMP5 has 339657 observations and 89 variables.
NOTE: DATA statement used (Total process time):
      real time           0.16 seconds
      cpu time            0.17 seconds
      

623  /* 339657*/
624  
625  proc sort data = comp5; by gvkey fyear; run;

NOTE: There were 339657 observations read from the data set WORK.COMP5.
NOTE: The data set WORK.COMP5 has 339657 observations and 89 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.26 seconds
      cpu time            0.46 seconds
      

626  proc expand data = comp5 out = comp6; by gvkey;
627      convert roabeg = roabeg_lag1 / transformout = (lag 1);
628      convert roabeg = roabeg_lag2 / transformout = (lag 2);
629      convert roabeg = roabeg_lag3 / transformout = (lag 3);
630      convert roabeg = roabeg_lag4 / transformout = (lag 4);
631      convert roabeg = roabeg_lag5 / transformout = (lag 5);
632      convert roabeg = roabeg_lag6 / transformout = (lag 6);
633      convert roabeg = roabeg_lag7 / transformout = (lag 7);
634      convert roabeg = roabeg_lag8 / transformout = (lag 8);
635      convert roabeg = roabeg_lag9 / transformout = (lag 9);
636      convert roabeg = roabeg_lag10 / transformout = (lag 10);
637  
638      convert roaavg = roaavg_lag1 / transformout = (lag 1);
639      convert roaavg = roaavg_lag2 / transformout = (lag 2);
640      convert roaavg = roaavg_lag3 / transformout = (lag 3);
641      convert roaavg = roaavg_lag4 / transformout = (lag 4);
642      convert roaavg = roaavg_lag5 / transformout = (lag 5);
643      convert roaavg = roaavg_lag6 / transformout = (lag 6);
644      convert roaavg = roaavg_lag7 / transformout = (lag 7);
645      convert roaavg = roaavg_lag8 / transformout = (lag 8);
646      convert roaavg = roaavg_lag9 / transformout = (lag 9);
647      convert roaavg = roaavg_lag10 / transformout = (lag 10);
648  
649      convert rosalebeg = rosalebeg_lag1 / transformout = (lag 1);
650      convert rosalebeg = rosalebeg_lag2 / transformout = (lag 2);
651      convert rosalebeg = rosalebeg_lag3 / transformout = (lag 3);
652      convert rosalebeg = rosalebeg_lag4 / transformout = (lag 4);
653      convert rosalebeg = rosalebeg_lag5 / transformout = (lag 5);
654      convert rosalebeg = rosalebeg_lag6 / transformout = (lag 6);
655      convert rosalebeg = rosalebeg_lag7 / transformout = (lag 7);
656      convert rosalebeg = rosalebeg_lag8 / transformout = (lag 8);
657      convert rosalebeg = rosalebeg_lag9 / transformout = (lag 9);
658      convert rosalebeg = rosalebeg_lag10 / transformout = (lag 10);
659  
660      convert ib = ib_lag1 / transformout = (lag 1);
661      convert ib = ib_lag2 / transformout = (lag 2);
662      convert ib = ib_lag3 / transformout = (lag 3);
663      convert ib = ib_lag4 / transformout = (lag 4);
664      convert ib = ib_lag5 / transformout = (lag 5);
665      convert ib = ib_lag6 / transformout = (lag 6);
666      convert ib = ib_lag7 / transformout = (lag 7);
667      convert ib = ib_lag8 / transformout = (lag 8);
668      convert ib = ib_lag9 / transformout = (lag 9);
669      convert ib = ib_lag10 / transformout = (lag 10);
670  
671      convert sale = sale_lag1 / transformout = (lag 1);
672      convert sale = sale_lag2 / transformout = (lag 2);
673      convert sale = sale_lag3 / transformout = (lag 3);
674      convert sale = sale_lag4 / transformout = (lag 4);
675      convert sale = sale_lag5 / transformout = (lag 5);
676      convert sale = sale_lag6 / transformout = (lag 6);
677      convert sale = sale_lag7 / transformout = (lag 7);
678      convert sale = sale_lag8 / transformout = (lag 8);
679      convert sale = sale_lag9 / transformout = (lag 9);
680      convert sale = sale_lag10 / transformout = (lag 10);
681  
682      convert market_share = market_share_lag1 / transformout = (lag 1);
683      convert market_share = market_share_lag2 / transformout = (lag 2);
684      convert market_share = market_share_lag3 / transformout = (lag 3);
685      convert market_share = market_share_lag4 / transformout = (lag 4);
686      convert market_share = market_share_lag5 / transformout = (lag 5);
687      convert market_share = market_share_lag6 / transformout = (lag 6);
688      convert market_share = market_share_lag7 / transformout = (lag 7);
689      convert market_share = market_share_lag8 / transformout = (lag 8);
690      convert market_share = market_share_lag9 / transformout = (lag 9);
691      convert market_share = market_share_lag10 / transformout = (lag 10);
692  
693      convert xrd = xrd_lag1 / transformout = (lag 1);
694      convert xrd = xrd_lag2 / transformout = (lag 2);
695      convert xrd = xrd_lag3 / transformout = (lag 3);
696      convert xrd = xrd_lag4 / transformout = (lag 4);
697      convert xrd = xrd_lag5 / transformout = (lag 5);
698      convert xrd = xrd_lag6 / transformout = (lag 6);
699      convert xrd = xrd_lag7 / transformout = (lag 7);
700      convert xrd = xrd_lag8 / transformout = (lag 8);
701      convert xrd = xrd_lag9 / transformout = (lag 9);
702      convert xrd = xrd_lag10 / transformout = (lag 10);
703  
704      convert xrd_at = xrd_at_lag1 / transformout = (lag 1);
705      convert xrd_at = xrd_at_lag2 / transformout = (lag 2);
706      convert xrd_at = xrd_at_lag3 / transformout = (lag 3);
707      convert xrd_at = xrd_at_lag4 / transformout = (lag 4);
708      convert xrd_at = xrd_at_lag5 / transformout = (lag 5);
709      convert xrd_at = xrd_at_lag6 / transformout = (lag 6);
710      convert xrd_at = xrd_at_lag7 / transformout = (lag 7);
711      convert xrd_at = xrd_at_lag8 / transformout = (lag 8);
712      convert xrd_at = xrd_at_lag9 / transformout = (lag 9);
713      convert xrd_at = xrd_at_lag10 / transformout = (lag 10);
714  
715      convert xrd_sale = xrd_sale_lag1 / transformout = (lag 1);
716      convert xrd_sale = xrd_sale_lag2 / transformout = (lag 2);
717      convert xrd_sale = xrd_sale_lag3 / transformout = (lag 3);
718      convert xrd_sale = xrd_sale_lag4 / transformout = (lag 4);
719      convert xrd_sale = xrd_sale_lag5 / transformout = (lag 5);
720      convert xrd_sale = xrd_sale_lag6 / transformout = (lag 6);
721      convert xrd_sale = xrd_sale_lag7 / transformout = (lag 7);
722      convert xrd_sale = xrd_sale_lag8 / transformout = (lag 8);
723      convert xrd_sale = xrd_sale_lag9 / transformout = (lag 9);
724      convert xrd_sale = xrd_sale_lag10 / transformout = (lag 10);
725  
726      convert xrd_ppent = xrd_ppent_lag1 / transformout = (lag 1);
727      convert xrd_ppent = xrd_ppent_lag2 / transformout = (lag 2);
728      convert xrd_ppent = xrd_ppent_lag3 / transformout = (lag 3);
729      convert xrd_ppent = xrd_ppent_lag4 / transformout = (lag 4);
730      convert xrd_ppent = xrd_ppent_lag5 / transformout = (lag 5);
731      convert xrd_ppent = xrd_ppent_lag6 / transformout = (lag 6);
732      convert xrd_ppent = xrd_ppent_lag7 / transformout = (lag 7);
733      convert xrd_ppent = xrd_ppent_lag8 / transformout = (lag 8);
734      convert xrd_ppent = xrd_ppent_lag9 / transformout = (lag 9);
735      convert xrd_ppent = xrd_ppent_lag10 / transformout = (lag 10);
736  
737      convert xrd_che = xrd_che_lag1 / transformout = (lag 1);
738      convert xrd_che = xrd_che_lag2 / transformout = (lag 2);
739      convert xrd_che = xrd_che_lag3 / transformout = (lag 3);
740      convert xrd_che = xrd_che_lag4 / transformout = (lag 4);
741      convert xrd_che = xrd_che_lag5 / transformout = (lag 5);
742      convert xrd_che = xrd_che_lag6 / transformout = (lag 6);
743      convert xrd_che = xrd_che_lag7 / transformout = (lag 7);
744      convert xrd_che = xrd_che_lag8 / transformout = (lag 8);
745      convert xrd_che = xrd_che_lag9 / transformout = (lag 9);
746      convert xrd_che = xrd_che_lag10 / transformout = (lag 10);
747  
748      convert at = at_lag1 / transformout = (lag 1);
749      convert at = at_lag2 / transformout = (lag 2);
750      convert at = at_lag3 / transformout = (lag 3);
751      convert at = at_lag4 / transformout = (lag 4);
752      convert at = at_lag5 / transformout = (lag 5);
753      convert at = at_lag6 / transformout = (lag 6);
754      convert at = at_lag7 / transformout = (lag 7);
755      convert at = at_lag8 / transformout = (lag 8);
756      convert at = at_lag9 / transformout = (lag 9);
757      convert at = at_lag10 / transformout = (lag 10);
758  
759      convert mve = mve_lag1 / transformout = (lag 1);
760      convert mve = mve_lag2 / transformout = (lag 2);
761      convert mve = mve_lag3 / transformout = (lag 3);
762      convert mve = mve_lag4 / transformout = (lag 4);
763      convert mve = mve_lag5 / transformout = (lag 5);
764      convert mve = mve_lag6 / transformout = (lag 6);
765      convert mve = mve_lag7 / transformout = (lag 7);
766      convert mve = mve_lag8 / transformout = (lag 8);
767      convert mve = mve_lag9 / transformout = (lag 9);
768      convert mve = mve_lag10 / transformout = (lag 10);
769  
770      convert ppent = ppent_lag1 / transformout = (lag 1);
771      convert ppent = ppent_lag2 / transformout = (lag 2);
772      convert ppent = ppent_lag3 / transformout = (lag 3);
773      convert ppent = ppent_lag4 / transformout = (lag 4);
774      convert ppent = ppent_lag5 / transformout = (lag 5);
775      convert ppent = ppent_lag6 / transformout = (lag 6);
776      convert ppent = ppent_lag7 / transformout = (lag 7);
777      convert ppent = ppent_lag8 / transformout = (lag 8);
778      convert ppent = ppent_lag9 / transformout = (lag 9);
779      convert ppent = ppent_lag10 / transformout = (lag 10);
780  
781  run;
NOTE: The data set WORK.COMP6 has 339657 observations and 230 variables.
NOTE: PROCEDURE EXPAND used (Total process time):
      real time           4.62 seconds
      cpu time            4.64 seconds
      

782  
783  PROC IMPORT OUT= WORK.patents DATAFILE= '..\..\Data\Datasets\KPSS_2019_public.csv'
784     DBMS=csv REPLACE;
785  RUN;

786   /**********************************************************************
787   *   PRODUCT:   SAS
788   *   VERSION:   9.4
789   *   CREATOR:   External File Interface
790   *   DATE:      24JUL24
791   *   DESC:      Generated SAS Datastep Code
792   *   TEMPLATE SOURCE:  (None Specified.)
793   ***********************************************************************/
794      data WORK.PATENTS    ;
795      %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
796      infile '..\..\Data\Datasets\KPSS_2019_public.csv' delimiter = ',' MISSOVER DSD lrecl=32767
796!  firstobs=2 ;
797         informat patent_num best32. ;
798         informat xi_real best32. ;
799         informat xi_nominal best32. ;
800         informat cites best32. ;
801         informat permno best32. ;
802         informat issue_date mmddyy10. ;
803         informat filing_date mmddyy10. ;
804         format patent_num best12. ;
805         format xi_real best12. ;
806         format xi_nominal best12. ;
807         format cites best12. ;
808         format permno best12. ;
809         format issue_date mmddyy10. ;
810         format filing_date mmddyy10. ;
811      input
812                  patent_num
813                  xi_real
814                  xi_nominal
815                  cites
816                  permno
817                  issue_date
818                  filing_date
819      ;
820      if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
821      run;

NOTE: The infile '..\..\Data\Datasets\KPSS_2019_public.csv' is:
      Filename=C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets\KPSS_2019_public.csv,
      RECFM=V,LRECL=32767,
      File Size (bytes)=172160533,
      Last Modified=06Dec2020:23:31:26,
      Create Time=20Nov2022:14:47:17

NOTE: 2950305 records were read from the infile '..\..\Data\Datasets\KPSS_2019_public.csv'.
      The minimum record length was 41.
      The maximum record length was 67.
NOTE: The data set WORK.PATENTS has 2950305 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           1.47 seconds
      cpu time            1.51 seconds
      

2950305 rows created in WORK.PATENTS from ..\..\Data\Datasets\KPSS_2019_public.csv.
  
  
  
NOTE: WORK.PATENTS data set was successfully created.
NOTE: The data set WORK.PATENTS has 2950305 observations and 7 variables.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           1.64 seconds
      cpu time            1.56 seconds
      

822  
823  
824  data patents; set patents;
825      filing_year = year(filing_date);
826      grant_year = year(issue_date);
827      active_year = 2017-grant_year;
828      WPC_p = 1+cites;
829  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      2 at 825:19   
NOTE: There were 2950305 observations read from the data set WORK.PATENTS.
NOTE: The data set WORK.PATENTS has 2950305 observations and 11 variables.
NOTE: DATA statement used (Total process time):
      real time           0.59 seconds
      cpu time            0.64 seconds
      

830  
831  proc sql;
832      create table patents as
833      select *, sum(xi_real) as patent_value, count(patent_num) as num_patents,
834      sum(cites) as forward_cites, sum (wpc_p) as wpc
835      from patents
836      group by permno,filing_year;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.PATENTS created, with 2950305 rows and 15 columns.

837  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           2.23 seconds
      cpu time            3.61 seconds
      

838  
839  data patents; set patents;
840      log_patent_value = log(patent_value);
841      if filing_year in (2019) then log_num_patents = log(1+num_patents*37.461);
842      if filing_year in (2018) then log_num_patents = log(1+num_patents*2.23);
843      if filing_year in (2017) then log_num_patents = log(1+num_patents*1.116);
844      if filing_year in (2016) then log_num_patents = log(1+num_patents*1.034);
845      if filing_year in (2015) then log_num_patents = log(1+num_patents*1.009);
846      if filing_year in (2014) then log_num_patents = log(1+num_patents*1.003);
847      if filing_year <2014 then log_num_patents = log(1+num_patents);
848      log_wpc = log(wpc);
849      log_forward_cites = log(1+forward_cites);
850      avg_forward_cites = log(1+forward_cites/grant_year);
851  run;

NOTE: Invalid argument to function LOG(0) at line 840 column 24.
patent_num=3754985 xi_real=0 xi_nominal=0 cites=3 permno=62827 issue_date=08/28/1973
filing_date=04/05/1971 filing_year=1971 grant_year=1973 active_year=44 WPC_p=4 patent_value=0
num_patents=5 forward_cites=22 wpc=27 log_patent_value=. log_num_patents=1.7917594692
log_wpc=3.295836866 log_forward_cites=3.1354942159 avg_forward_cites=0.0110888233 _ERROR_=1
_N_=2211265
NOTE: Invalid argument to function LOG(0) at line 840 column 24.
patent_num=3745504 xi_real=0 xi_nominal=0 cites=5 permno=62827 issue_date=07/10/1973
filing_date=03/22/1971 filing_year=1971 grant_year=1973 active_year=44 WPC_p=6 patent_value=0
num_patents=5 forward_cites=22 wpc=27 log_patent_value=. log_num_patents=1.7917594692
log_wpc=3.295836866 log_forward_cites=3.1354942159 avg_forward_cites=0.0110888233 _ERROR_=1
_N_=2211266
NOTE: Invalid argument to function LOG(0) at line 840 column 24.
patent_num=3722995 xi_real=0 xi_nominal=0 cites=4 permno=62827 issue_date=03/27/1973
filing_date=04/05/1971 filing_year=1971 grant_year=1973 active_year=44 WPC_p=5 patent_value=0
num_patents=5 forward_cites=22 wpc=27 log_patent_value=. log_num_patents=1.7917594692
log_wpc=3.295836866 log_forward_cites=3.1354942159 avg_forward_cites=0.0110888233 _ERROR_=1
_N_=2211267
NOTE: Invalid argument to function LOG(0) at line 840 column 24.
patent_num=3722453 xi_real=0 xi_nominal=0 cites=6 permno=62827 issue_date=03/27/1973
filing_date=04/05/1971 filing_year=1971 grant_year=1973 active_year=44 WPC_p=7 patent_value=0
num_patents=5 forward_cites=22 wpc=27 log_patent_value=. log_num_patents=1.7917594692
log_wpc=3.295836866 log_forward_cites=3.1354942159 avg_forward_cites=0.0110888233 _ERROR_=1
_N_=2211268
NOTE: Invalid argument to function LOG(0) at line 840 column 24.
patent_num=3711197 xi_real=0 xi_nominal=0 cites=4 permno=62827 issue_date=01/16/1973
filing_date=04/05/1971 filing_year=1971 grant_year=1973 active_year=44 WPC_p=5 patent_value=0
num_patents=5 forward_cites=22 wpc=27 log_patent_value=. log_num_patents=1.7917594692
log_wpc=3.295836866 log_forward_cites=3.1354942159 avg_forward_cites=0.0110888233 _ERROR_=1
_N_=2211269
NOTE: Mathematical operations could not be performed at the following places. The results of the 
      operations have been set to missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      5 at 840:24   
NOTE: There were 2950305 observations read from the data set WORK.PATENTS.
NOTE: The data set WORK.PATENTS has 2950305 observations and 20 variables.
NOTE: DATA statement used (Total process time):
      real time           1.34 seconds
      cpu time            1.28 seconds
      

852  
853  
854  proc sort data= patents (keep = permno num_patents log_wpc wpc log_num_patents
854! avg_forward_cites forward_cites log_forward_cites
855      patent_value log_patent_value filing_year) out= patents2 nodupkey; by permno filing_year;
855! run;

NOTE: There were 2950305 observations read from the data set WORK.PATENTS.
NOTE: 2859073 observations with duplicate key values were deleted.
NOTE: The data set WORK.PATENTS2 has 91232 observations and 11 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.71 seconds
      cpu time            1.39 seconds
      

856  
857  
858  proc sql;
859      create table comp7 as select a.*, b.*
860      from comp6 as a left join patents2 as b
861      on a.lpermno = b.permno and a.fyear= b.filing_year
862      order by lpermno, fyear;
NOTE: Table WORK.COMP7 created, with 339657 rows and 241 columns.

863  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           2.55 seconds
      cpu time            3.07 seconds
      

864  
865  data comp8; set comp7;
866      if num_patents =. then num_patents =0;
867      if log_wpc =. then log_wpc =0;
868      if log_num_patents =. then log_num_patents =0;
869      if forward_cites =. then forward_cites =0;
870      if log_forward_cites =. then log_forward_cites =0;
871      if patent_value =. then patent_value =0;
872      if log_patent_value =. then log_patent_value =0;
873      if avg_forward_cites =. then avg_forward_cites =0;
874  run;

NOTE: There were 339657 observations read from the data set WORK.COMP7.
NOTE: The data set WORK.COMP8 has 339657 observations and 241 variables.
NOTE: DATA statement used (Total process time):
      real time           0.97 seconds
      cpu time            0.81 seconds
      

875  
876  proc sort data = comp8; by gvkey fyear; run;

NOTE: There were 339657 observations read from the data set WORK.COMP8.
NOTE: The data set WORK.COMP8 has 339657 observations and 241 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           1.29 seconds
      cpu time            1.50 seconds
      

877  
878  data comp9;
879      set comp8;
880      array NumVar patent_value_lag1 -patent_value_lag10 log_num_patents_lag1
880! -log_num_patents_lag10
881      num_patents_lag1-num_patents_lag10;
882      do over NumVar;
883      if NumVar<0 or 0<NumVar<1 then NumVar =0;
884     end;
885  run;

NOTE: There were 339657 observations read from the data set WORK.COMP8.
NOTE: The data set WORK.COMP9 has 339657 observations and 271 variables.
NOTE: DATA statement used (Total process time):
      real time           1.46 seconds
      cpu time            1.06 seconds
      

886  
887  data comp_tmp (keep =gvkey datadate
888      at_lag1 -at_lag10  ppent_lag1 - ppent_lag10
889      mve_lag1 -mve_lag10 xrd_lag1 -xrd_lag10
890      xrd_at_lag1 -xrd_at_lag10 xrd_sale_lag1 -xrd_sale_lag10 xrd_che_lag1 -xrd_che_lag10
891      xrd_ppent_lag1 -xrd_ppent_lag10
892      patent_value_lag1 -patent_value_lag10 log_num_patents_lag1 -log_num_patents_lag10
893      num_patents_lag1 -num_patents_lag10
894      sale_lag1 -sale_lag10 market_share_lag1 -market_share_lag10
895      roabeg_lag1 - roabeg_lag10 roaavg_lag1 - roaavg_lag10  ib_lag1 -ib_lag10 rosalebeg_lag1
895! -rosalebeg_lag10
896  
897      naics3 naics2 sic2 sic1 lpermno cik sich2 siccd
898      roaavg roabeg ib rosalebeg
899      xrd xrd_at xrd_sale xrd_che xrd_ppent
900      log_num_patents num_patents patent_value
901      sale market_share
902      at mve ppent
903      mtb LEV ch_sale CASH hi datadate mve tangibility); set comp9;
904      ;
905  run;

NOTE: There were 339657 observations read from the data set WORK.COMP9.
NOTE: The data set WORK.COMP_TMP has 339657 observations and 203 variables.
NOTE: DATA statement used (Total process time):
      real time           0.50 seconds
      cpu time            0.49 seconds
      

906  
907  
908  proc sort data = data.seg20221120 out= Ctmp; by cgvkey srcdate; run;

NOTE: There were 67342 observations read from the data set DATA.SEG20221120.
NOTE: The data set WORK.CTMP has 67342 observations and 26 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.08 seconds
      cpu time            0.06 seconds
      

909  
910  data Ctmp; set Ctmp;
911      drop sale disclosed_sale avg_sale naics2 sic2;
912  run;

NOTE: There were 67342 observations read from the data set WORK.CTMP.
NOTE: The data set WORK.CTMP has 67342 observations and 21 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

913  
914    data comp_tmpc;
915        set comp_tmp;
916            rename mve_lag4 = cmve_lag4;
917            rename xrd_lag4 = cxrd_lag4;
918            rename mve_lag5 = cmve_lag5;
919            rename xrd_lag5 = cxrd_lag5;
920            rename gvkey = cgvkey lpermno = cpermno naics3 = cnaics3 naics2 = cnaics2 sic2 =
920! csic2 sic1 = csic1 datadate = cdatadate cik = ccik
921            roabeg = croabeg roaavg =croaavg ib = cib rosalebeg = crosalebeg
922            xrd = cxrd xrd_sale = cxrd_sale xrd_at = cxrd_at xrd_che = cxrd_che
923            xrd_ppent = cxrd_ppent
924  
925            sale = csale market_share = cmarket_share
926            at = cat mve =cmve  ppent = cppent
927            ch_sale = cch_sale tangibility = ctangibility hi = chi CASH = cCASH LEV = cLEV  mtb
927! = cmtb;
928    run;

NOTE: There were 339657 observations read from the data set WORK.COMP_TMP.
NOTE: The data set WORK.COMP_TMPC has 339657 observations and 203 variables.
NOTE: DATA statement used (Total process time):
      real time           0.96 seconds
      cpu time            0.53 seconds
      

929  
930  proc sql;
931    create table Ctmp2 as
932      select a.*, b.*
933      from Ctmp a
934      left join comp_tmpc b
935      on a.cgvkey = b.cgvkey and a.srcdate-365*2 <= b.cdatadate <= a.srcdate;
WARNING: Variable cgvkey already exists on file WORK.CTMP2.
WARNING: Variable cdatadate already exists on file WORK.CTMP2.
WARNING: Variable csic2 already exists on file WORK.CTMP2.
WARNING: Variable cnaics2 already exists on file WORK.CTMP2.
NOTE: Table WORK.CTMP2 created, with 144191 rows and 220 columns.

936  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.85 seconds
      cpu time            2.06 seconds
      

937  
938  proc sort data=Ctmp2 out =Ctmp2; by cgvkey sgvkey srcdate descending cdatadate; run;

NOTE: There were 144191 observations read from the data set WORK.CTMP2.
NOTE: The data set WORK.CTMP2 has 144191 observations and 220 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.43 seconds
      cpu time            0.56 seconds
      

939  proc sort data=Ctmp2 out =Ctmp2 nodupkey; by cgvkey sgvkey srcdate; run;

NOTE: There were 144191 observations read from the data set WORK.CTMP2.
NOTE: 76849 observations with duplicate key values were deleted.
NOTE: The data set WORK.CTMP2 has 67342 observations and 220 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.44 seconds
      cpu time            0.48 seconds
      

940  
941  data Ctmp2; set Ctmp2;
942  if cdatadate =. then delete; run;

NOTE: There were 67342 observations read from the data set WORK.CTMP2.
NOTE: The data set WORK.CTMP2 has 63533 observations and 220 variables.
NOTE: DATA statement used (Total process time):
      real time           0.13 seconds
      cpu time            0.12 seconds
      

943  
944  data Ctmp2; set Ctmp2;
945  if cgvkey =sgvkey then delete; run;

NOTE: There were 63533 observations read from the data set WORK.CTMP2.
NOTE: The data set WORK.CTMP2 has 63284 observations and 220 variables.
NOTE: DATA statement used (Total process time):
      real time           0.12 seconds
      cpu time            0.10 seconds
      

946  
947  proc sort data=Ctmp2 out =Ctmp3 nodupkey; by cgvkey sgvkey srcdate; run;

NOTE: There were 63284 observations read from the data set WORK.CTMP2.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CTMP3 has 63284 observations and 220 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.21 seconds
      cpu time            0.18 seconds
      

948  
949  data Ctmp3; set Ctmp3; by cgvkey sgvkey;
950      p_salecs_1 = ifn(first.sgvkey, ., lag(p_salecs));
951      p_salecs_2 = ifn(first.sgvkey, ., lag(lag(p_salecs)));
952      p_salecs_3 = ifn(first.sgvkey, ., lag(lag(lag(p_salecs))));
953  
954      p_salecs_4 = ifn(first.sgvkey, ., lag(lag(lag(lag(p_salecs)))));
955      p_salecs_5 = ifn(first.sgvkey, ., lag(lag(lag(lag(lag(p_salecs))))));
956  run;

NOTE: There were 63284 observations read from the data set WORK.CTMP3.
NOTE: The data set WORK.CTMP3 has 63284 observations and 225 variables.
NOTE: DATA statement used (Total process time):
      real time           0.16 seconds
      cpu time            0.15 seconds
      

957  
958  data Ctmp4; set Ctmp3;
959      if p_salecs_1 =. then p_salecs_1 =0;
960      if p_salecs_2 =. then p_salecs_2 =0;
961      if p_salecs_3 =. then p_salecs_3 =0;
962  
963      if p_salecs_4 =. then p_salecs_4 =0;
964      if p_salecs_5 =. then p_salecs_5 =0;
965      p_salecs_3_1 = (p_salecs_3 + p_salecs_1 + p_salecs_2)/3;
966  run;

NOTE: There were 63284 observations read from the data set WORK.CTMP3.
NOTE: The data set WORK.CTMP4 has 63284 observations and 226 variables.
NOTE: DATA statement used (Total process time):
      real time           0.15 seconds
      cpu time            0.14 seconds
      

967  
968  proc sort data = Ctmp4 out=ctmp5 nodupkey; by cgvkey sgvkey year; run;

NOTE: There were 63284 observations read from the data set WORK.CTMP4.
NOTE: 6 observations with duplicate key values were deleted.
NOTE: The data set WORK.CTMP5 has 63278 observations and 226 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.24 seconds
      cpu time            0.21 seconds
      

969  
970  proc sort data = Ctmp5; by sgvkey year; run;

NOTE: There were 63278 observations read from the data set WORK.CTMP5.
NOTE: The data set WORK.CTMP5 has 63278 observations and 226 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.22 seconds
      cpu time            0.23 seconds
      

971  proc rank data = Ctmp5 out = Ctmp5 ties=low descending;
972  by sgvkey year;
973  var p_salecs_3_1;
974  ranks r_p_salecs_3_1; run;

NOTE: There were 63278 observations read from the data set WORK.CTMP5.
NOTE: The data set WORK.CTMP5 has 63278 observations and 227 variables.
NOTE: PROCEDURE RANK used (Total process time):
      real time           0.27 seconds
      cpu time            0.26 seconds
      

975  
976  /*****************************************************/
977  /*Merge customer trade secrets and redaction*/
978  /*****************************************************/
979  
980  proc import datafile="..\..\Data\Datasets\edgar_pc_0404.xlsx"
981          out= edgar_pc dbms=xlsx replace;
982      getnames=yes;
983  run;

NOTE: One or more variables were converted because the data type is not supported by the V9 
      engine. For more details, run with options MSGLEVEL=I.
NOTE: The import data set has 14514 observations and 42 variables.
NOTE: WORK.EDGAR_PC data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           2.53 seconds
      cpu time            2.46 seconds
      

984  
985  proc sql;
986    create table Ctmp6 as
987    select a.*, b.*
988    from Ctmp5 a
989    left join edgar_pc b
990    on a.cgvkey = b.cgvkey and a.year = b.year;
WARNING: Variable year already exists on file WORK.CTMP6.
WARNING: Variable CCUSIP already exists on file WORK.CTMP6.
WARNING: Variable cgvkey already exists on file WORK.CTMP6.
WARNING: Variable datadate already exists on file WORK.CTMP6.
NOTE: Table WORK.CTMP6 created, with 63278 rows and 265 columns.

991  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.49 seconds
      cpu time            0.54 seconds
      

992  
993  data temp.Ctmp7_20221217; set Ctmp6;
994  run;

NOTE: There were 63278 observations read from the data set WORK.CTMP6.
NOTE: The data set TEMP.CTMP7_20221217 has 63278 observations and 265 variables.
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.23 seconds
      

995  
996  proc export data=temp.Ctmp7_20221217
997      outfile="..\..\Data\JAR\temp\Ctmp7_20221217.dta"
998      DBMS= dta REPLACE;
999  run;

NOTE: The export data set has 63278 observations and 265 variables.
NOTE: "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp\Ctmp7_20221217.dta" file was 
      successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           1.17 seconds
      cpu time            1.06 seconds
      

1000  
1001  proc import datafile = "..\..\Data\JAR\temp\supplier_year_tss_xvar_final.dta"
1002   out = work.supplier_year_tss_xvar_final
1003   dbms = dta
1004   replace;
1005  run;

NOTE: One or more variables were converted because the data type is not supported by the V9 
      engine. For more details, run with options MSGLEVEL=I.
NOTE: The import data set has 39114 observations and 57 variables.
NOTE: WORK.SUPPLIER_YEAR_TSS_XVAR_FINAL data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.40 seconds
      cpu time            0.40 seconds
      

1006  
1007  proc sql;
1008    create table S18 as
1009      select a.*, b.roabeg, b.AT, b.mtb, b.ch_sale, b.tangibility,b.sic1,b.sich2
1010      from supplier_year_tss_xvar_final a
1011      left join comp_tmp b
1012      on a.sgvkey = b.gvkey and a.srcdate= b.datadate;
NOTE: Table WORK.S18 created, with 39114 rows and 64 columns.

1013  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.32 seconds
      cpu time            1.61 seconds
      

1014  
1015  /*Drop the financial and utility industry from the suppliers*/
1016  data S18; set S18;
1017      if sich2 in (60,61,62,63,64,65,66,67,68, 69, 49) then delete;
1018  run;

NOTE: There were 39114 observations read from the data set WORK.S18.
NOTE: The data set WORK.S18 has 36169 observations and 64 variables.
NOTE: DATA statement used (Total process time):
      real time           0.10 seconds
      cpu time            0.10 seconds
      

1019  
1020  proc sort data = S18 nodupkey; by sgvkey year; run;

NOTE: There were 36169 observations read from the data set WORK.S18.
NOTE: 7 observations with duplicate key values were deleted.
NOTE: The data set WORK.S18 has 36162 observations and 64 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.12 seconds
      cpu time            0.09 seconds
      

1021  
1022  
1023  data S20; set S18;
1024      SCUSIP8=substr(SCUSIP,1,8);
1025      SCUSIP6=substr(SCUSIP,1,6);
1026      format SCUSIP6 $6.;
1027      sic3 = int(sic1/10);
1028  run;

NOTE: There were 36162 observations read from the data set WORK.S18.
NOTE: The data set WORK.S20 has 36162 observations and 67 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.09 seconds
      

1029  
1030  data temp.S_20221217; set S20; run;

NOTE: There were 36162 observations read from the data set WORK.S20.
NOTE: The data set TEMP.S_20221217 has 36162 observations and 67 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1031  
1032  /********************************************************************************************
1032! ****************/
1033  /*  Create customer switch var
1034  /********************************************************************************************
1034! ****************/
1035  Libname data '..\..\Data\Datasets';
NOTE: Libref DATA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets
1036  Libname temp '..\..\Data\JAR\temp';
NOTE: Libref TEMP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp
1037  
1038  data scs; set temp.scs_sic3;
1039      wanted =1;
1040  run;

NOTE: There were 7083268 observations read from the data set TEMP.SCS_SIC3.
NOTE: The data set WORK.SCS has 7083268 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           3.30 seconds
      cpu time            3.04 seconds
      

1041  
1042  proc sort data = scs out =temp nodupkey; by sgvkey year rgvkey; run;

NOTE: There were 7083268 observations read from the data set WORK.SCS.
NOTE: 4971259 observations with duplicate key values were deleted.
NOTE: The data set WORK.TEMP has 2112009 observations and 14 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           3.78 seconds
      cpu time            9.47 seconds
      

1043  
1044  proc sql;
1045    create table test as
1046      select a.*, b.wanted as wanted_rgvkey
1047      from data.sample_mna_20221217 a
1048      left join temp b
1049      on a.gvkey = b.sgvkey and year(a.dateann)=b.year and a.counterparty_gvkey = rgvkey;
NOTE: Table WORK.TEST created, with 73890 rows and 37 columns.

1050  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.85 seconds
      cpu time            0.90 seconds
      

1051  
1052  
1053  proc sort data = scs out =temp nodupkey; by sgvkey year rsgvkey; run;

NOTE: There were 7083268 observations read from the data set WORK.SCS.
NOTE: 4272648 observations with duplicate key values were deleted.
NOTE: The data set WORK.TEMP has 2810620 observations and 14 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           3.39 seconds
      cpu time            9.00 seconds
      

1054  
1055  data temp; set temp;
1056  where rsgvkey ^=.; run;

NOTE: There were 2780855 observations read from the data set WORK.TEMP.
      WHERE rsgvkey not = .;
NOTE: The data set WORK.TEMP has 2780855 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           1.32 seconds
      cpu time            1.32 seconds
      

1057  
1058  proc sql;
1059    create table test as
1060      select a.*, b.wanted as wanted_rsgvkey
1061      from test a
1062      left join temp b
1063      on a.gvkey = b.sgvkey and year(a.dateann)=b.year and a.counterparty_gvkey = rsgvkey;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.TEST created, with 73890 rows and 38 columns.

1064  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.25 seconds
      cpu time            2.26 seconds
      

1065  
1066  
1067  data test2;
1068      set test;
1069      array NumVar wanted_rgvkey wanted_rsgvkey;
1070      do over NumVar;
1071        if NumVar^=. then wanted =1;
1072     end;
1073  run;

NOTE: There were 73890 observations read from the data set WORK.TEST.
NOTE: The data set WORK.TEST2 has 73890 observations and 39 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.09 seconds
      

1074  
1075  
1076  data mna_wlinks_sic3; set test2;
1077  if wanted =. then wanted =0;
1078  if wanted_rgvkey =. then wanted_rgvkey =0;
1079  if wanted_rsgvkey =. then wanted_rsgvkey =0;
1080  if wanted =0 then unwanted =1; else unwanted =0; run;

NOTE: There were 73890 observations read from the data set WORK.TEST2.
NOTE: The data set WORK.MNA_WLINKS_SIC3 has 73890 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.09 seconds
      

1081  
1082  
1083  data mna_wlinks; set mna_wlinks_sic3; run;

NOTE: There were 73890 observations read from the data set WORK.MNA_WLINKS_SIC3.
NOTE: The data set WORK.MNA_WLINKS has 73890 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds
      

1084  
1085  data segcust76_19; set data.segcust76_19;
1086          where   1989<= year(srcdate) <= 2019;
1087  run;

NOTE: There were 518766 observations read from the data set DATA.SEGCUST76_19.
      WHERE (1989<=YEAR(srcdate)) and (YEAR(srcdate)<=2019);
NOTE: The data set WORK.SEGCUST76_19 has 518766 observations and 11 variables.
NOTE: DATA statement used (Total process time):
      real time           0.50 seconds
      cpu time            0.29 seconds
      

1088  
1089  data segcust; set segcust76_19;
1090          if cnms = '' then delete;
1091  run;

NOTE: There were 518766 observations read from the data set WORK.SEGCUST76_19.
NOTE: The data set WORK.SEGCUST has 504522 observations and 11 variables.
NOTE: DATA statement used (Total process time):
      real time           0.15 seconds
      cpu time            0.14 seconds
      

1092  
1093  proc sort data = segcust out = check nodupkey;
1094    by  gvkey year;
1095  run;

NOTE: There were 504522 observations read from the data set WORK.SEGCUST.
NOTE: 378300 observations with duplicate key values were deleted.
NOTE: The data set WORK.CHECK has 126222 observations and 11 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.18 seconds
      cpu time            0.39 seconds
      

1096  
1097  data segcust;
1098  set segcust;
1099          No_name =findw(strip(cnms), "Customers",' ') or findw(strip(cnms), "customers",' ')
1100          or findw(strip(cnms), "Customer",' ') or findw(strip(cnms), "customer",' ') or
1100! findw(strip(cnms), "CUSTOMERS",' ')
1101          or findw(strip(cnms), "Not Reported",' ') or findw(strip(cnms), "Not reported",' ')
1101! or findw(strip(cnms), "Not Repported",' ')
1102          or findw(strip(cnms), "NOT REPORTED",' ');
1103          if No_name ^=0 then delete;
1104  run;

NOTE: There were 504522 observations read from the data set WORK.SEGCUST.
NOTE: The data set WORK.SEGCUST has 384124 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.60 seconds
      cpu time            0.59 seconds
      

1105  
1106  proc sql;
1107          create table segcust as
1108          select *, sum(salecs) as total_salecs
1109          from segcust
1110          group by gvkey,cnms, year;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.SEGCUST created, with 384124 rows and 13 columns.

1111  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.36 seconds
      cpu time            0.51 seconds
      

1112  
1113  proc sort data = segcust out = segcust2 nodupkey;
1114    by  gvkey cnms year;
1115  run;

NOTE: There were 384124 observations read from the data set WORK.SEGCUST.
NOTE: 33530 observations with duplicate key values were deleted.
NOTE: The data set WORK.SEGCUST2 has 350594 observations and 13 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.13 seconds
      cpu time            0.26 seconds
      

1116  
1117  data link; set data.seglink;
1118          year = year(srcdate);
1119          where 1976<=year(srcdate) <=2019;
1120  run;

NOTE: There were 109503 observations read from the data set DATA.SEGLINK.
      WHERE (1976<=YEAR(srcdate)) and (YEAR(srcdate)<=2019);
NOTE: The data set WORK.LINK has 109503 observations and 15 variables.
NOTE: DATA statement used (Total process time):
      real time           0.11 seconds
      cpu time            0.09 seconds
      

1121  
1122  proc sort data=link out =tmp nodupkey; by gvkey cid year; run;

NOTE: There were 109503 observations read from the data set WORK.LINK.
NOTE: 99 observations with duplicate key values were deleted.
NOTE: The data set WORK.TMP has 109404 observations and 15 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1123  
1124  proc sql;
1125    create table segcust3 as
1126      select a.*, b.CGVKEY, b.CTIC, b.CCUSIP, b.CCONM, b.CNMS as CCNMS, b.CID as CCID, b.gvkey,
1126!  b.SCUSIP
1127      from segcust2 a
1128          left join tmp b on a.CID =b.CID and a.gvkey =b.gvkey and year(a.srcdate) =
1128! year(b.srcdate)
1129          order by a.gvkey, a.cid, a.srcdate;
WARNING: Variable GVKEY already exists on file WORK.SEGCUST3.
NOTE: Table WORK.SEGCUST3 created, with 350594 rows and 20 columns.

1130  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.69 seconds
      cpu time            1.10 seconds
      

1131  
1132  proc sort data = segcust3 out = segcust3;
1133    by cnms year;
1134  run;

NOTE: There were 350594 observations read from the data set WORK.SEGCUST3.
NOTE: The data set WORK.SEGCUST3 has 350594 observations and 20 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.26 seconds
      cpu time            0.45 seconds
      

1135  
1136  
1137  data segcust3; set segcust3;
1138          if cgvkey = '' and ctype = 'COMPANY' then cgvkey = '10000001';
1139          if ctype in('GOVDOM', 'GOVERN', 'MARKET', 'GEOREG', 'GOVFRN', 'GOVSTATE', 'GOVLOC')
1139! then cgvkey = '10000003';
1140  run;

NOTE: There were 350594 observations read from the data set WORK.SEGCUST3.
NOTE: The data set WORK.SEGCUST3 has 350594 observations and 20 variables.
NOTE: DATA statement used (Total process time):
      real time           0.20 seconds
      cpu time            0.20 seconds
      

1141  
1142  
1143  data segcust4; set segcust3;
1144          where cgvkey not in ('','10000001','10000003')
1145          and gvkey not in ('') and year not in (.);
1146  run;

NOTE: There were 86798 observations read from the data set WORK.SEGCUST3.
      WHERE cgvkey not in (' ', '10000001', '10000003') and (gvkey not = ' ') and (year not = .);
NOTE: The data set WORK.SEGCUST4 has 86798 observations and 20 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.09 seconds
      

1147  
1148  data segcust4; set segcust4;
1149          cgvkey1 = input(cgvkey, 8.);
1150          sgvkey = input(gvkey, 8.);
1151          drop cgvkey gvkey salecs cid ccid TIME gareac gareat sid No_name;
1152          rename cgvkey1 = cgvkey;
1153  run;

WARNING: The variable TIME in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 86798 observations read from the data set WORK.SEGCUST4.
NOTE: The data set WORK.SEGCUST4 has 86798 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
      

1154  
1155  data compa78_20; set data.compa78_20_20220410;
1156          gvkey1 = input(gvkey, 8.);
1157          drop gvkey;
1158          rename gvkey1 = gvkey;
1159  run;

NOTE: There were 404385 observations read from the data set DATA.COMPA78_20_20220410.
NOTE: The data set WORK.COMPA78_20 has 404385 observations and 63 variables.
NOTE: DATA statement used (Total process time):
      real time           0.26 seconds
      cpu time            0.18 seconds
      

1160  
1161  proc sql;
1162    create table segcust5 as
1163      select a.*, b.naics2, b.sic2, b.sale
1164      from segcust4 a
1165          left join compa78_20 b
1166          on a.sgvkey = b.gvkey and a.year = b.fyear;
NOTE: Table WORK.SEGCUST5 created, with 86798 rows and 16 columns.

1167  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.54 seconds
      cpu time            0.68 seconds
      

1168  
1169  
1170  
1171  proc sql;
1172          create table segcust6 as
1173          select *, sum(total_salecs) as disclosed_sale, avg(total_salecs) as
1173! avg_sale,count(distinct cgvkey) as tc
1174          from segcust5
1175          group by sgvkey, year;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.SEGCUST6 created, with 86798 rows and 19 columns.

1176  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.27 seconds
      cpu time            0.28 seconds
      

1177  
1178  proc sql;
1179          create table segcust6 as
1180          select *, (total_salecs/sale) as p_salecs
1181          from segcust6
1182          group by sgvkey, cgvkey, year;
WARNING: A GROUP BY clause has been transformed into an ORDER BY clause because neither the SELECT 
         clause nor the optional HAVING clause of the associated table-expression referenced a 
         summary function.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.SEGCUST6 created, with 86798 rows and 20 columns.

1183  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.16 seconds
      cpu time            0.21 seconds
      

1184  
1185  
1186  data segcust7; set segcust6;
1187      where sale ^=. and p_salecs ^=.;
1188  run;

NOTE: There were 67316 observations read from the data set WORK.SEGCUST6.
      WHERE (sale not = .) and (p_salecs not = .);
NOTE: The data set WORK.SEGCUST7 has 67316 observations and 20 variables.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.06 seconds
      

1189  
1190  proc sort data = segcust7; by sgvkey year descending p_salecs; run;

NOTE: There were 67316 observations read from the data set WORK.SEGCUST7.
NOTE: The data set WORK.SEGCUST7 has 67316 observations and 20 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.11 seconds
      cpu time            0.12 seconds
      

1191  
1192  
1193  proc rank data = segcust7 out = segcust7 ties=low descending;
1194      by sgvkey year;
1195      var p_salecs;
1196  ranks r_p_salecs; run;

NOTE: There were 67316 observations read from the data set WORK.SEGCUST7.
NOTE: The data set WORK.SEGCUST7 has 67316 observations and 21 variables.
NOTE: PROCEDURE RANK used (Total process time):
      real time           0.22 seconds
      cpu time            0.21 seconds
      

1197  
1198  
1199  data C; set segcust7;
1200      if cgvkey =sgvkey then delete;
1201  run;

NOTE: There were 67316 observations read from the data set WORK.SEGCUST7.
NOTE: The data set WORK.C has 67038 observations and 21 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds
      

1202  
1203  proc sort data = C out =temp; by sgvkey cgvkey descending year; run;

NOTE: There were 67038 observations read from the data set WORK.C.
NOTE: The data set WORK.TEMP has 67038 observations and 21 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.16 seconds
      cpu time            0.15 seconds
      

1204  proc sort data = temp (keep = sgvkey year) out =temp nodupkey; by sgvkey; run;

NOTE: There were 67038 observations read from the data set WORK.TEMP.
NOTE: 60299 observations with duplicate key values were deleted.
NOTE: The data set WORK.TEMP has 6739 observations and 2 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
      

1205  
1206  proc sql;
1206!           create table C2 as
1207      select a.*,
1208      b.year as last_year_database from C as a left join temp as b
1209      on a.sgvkey = b.sgvkey
1210      order by a.sgvkey, a.cgvkey, a.year;
NOTE: Table WORK.C2 created, with 67038 rows and 22 columns.

1211  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.21 seconds
      cpu time            0.25 seconds
      

1212  
1213  
1214  proc sort data = C2 (keep = cgvkey sgvkey SCUSIP year p_salecs r_p_salecs srcdate
1215  sale last_year_database) out = C3; by sgvkey srcdate; run;

NOTE: There were 67038 observations read from the data set WORK.C2.
NOTE: The data set WORK.C3 has 67038 observations and 9 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
      

1216  
1217  proc sort data = C3 nodupkey; by sgvkey cgvkey srcdate; run;

NOTE: There were 67038 observations read from the data set WORK.C3.
NOTE: 305 observations with duplicate key values were deleted.
NOTE: The data set WORK.C3 has 66733 observations and 9 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
      

1218  
1219  proc sql;
1219!           create table C4 as
1220      select a.*,
1221      b.year as lead_year from C3 as a left join C3 as b
1222      on a.sgvkey = b.sgvkey & a.cgvkey = b.cgvkey &
1223      b.srcdate -365-30 <= a.srcdate<= b.srcdate-365
1224      order by a.sgvkey, a.cgvkey, a.srcdate;
NOTE: Table WORK.C4 created, with 66733 rows and 10 columns.

1225  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.19 seconds
      cpu time            0.21 seconds
      

1226  
1227  data C5; set  C4;
1228      if lead_year =. and year ^= last_year_database then continuing_cust =0; else
1228! continuing_cust =1;
1229  run;

NOTE: There were 66733 observations read from the data set WORK.C4.
NOTE: The data set WORK.C5 has 66733 observations and 11 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds
      

1230  proc sort data = C5 out = C5; by sgvkey cgvkey srcdate lead_year ; run;

NOTE: There were 66733 observations read from the data set WORK.C5.
NOTE: The data set WORK.C5 has 66733 observations and 11 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.07 seconds
      cpu time            0.04 seconds
      

1231  proc sort data = C5 out = C6 nodupkey; by cgvkey sgvkey srcdate; run;

NOTE: There were 66733 observations read from the data set WORK.C5.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.C6 has 66733 observations and 11 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

1232  
1233  
1234  data target; set mna_wlinks;
1235  where identity = 'tar'; run;

NOTE: There were 11064 observations read from the data set WORK.MNA_WLINKS.
      WHERE identity='tar';
NOTE: The data set WORK.TARGET has 11064 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds
      

1236  
1237  proc sort data = target out =target nodupkey; by gvkey dateann; run;

NOTE: There were 11064 observations read from the data set WORK.TARGET.
NOTE: 65 observations with duplicate key values were deleted.
NOTE: The data set WORK.TARGET has 10999 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds
      

1238  
1239  proc sql;
1239!           create table C8 as
1240      select a.*,
1241      b.target_d as target_1, b.wanted as wanted_target_1, b.year as ann_year, b.dateann,
1242      b.counterparty_gvkey as agvkey from C6 as a left join target as b
1243      on a.sgvkey = b.gvkey &
1244      a.srcdate <= b.dateann <= a.srcdate+365
1245      order by a.sgvkey, a.srcdate;
NOTE: Table WORK.C8 created, with 67157 rows and 16 columns.

1246  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.15 seconds
      cpu time            0.17 seconds
      

1247  
1248  proc sort data = C8 out = C8; by cgvkey sgvkey srcdate descending target_1; run;

NOTE: There were 67157 observations read from the data set WORK.C8.
NOTE: The data set WORK.C8 has 67157 observations and 16 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1249  proc sort data = C8 out = C8 nodupkey; by cgvkey sgvkey srcdate; run;

NOTE: There were 67157 observations read from the data set WORK.C8.
NOTE: 424 observations with duplicate key values were deleted.
NOTE: The data set WORK.C8 has 66733 observations and 16 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
      

1250  
1251  proc sql;
1251!           create table C9 as
1252      select a.*,
1253      b.year as lead_year_a from C8 as a left join C6 as b
1254      on a.agvkey = b.sgvkey & a.cgvkey = b.cgvkey &
1255      b.srcdate-365 <= a.dateann <= b.srcdate
1256      order by a.agvkey, a.cgvkey, a.dateann;
NOTE: Table WORK.C9 created, with 66739 rows and 17 columns.

1257  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.16 seconds
      cpu time            0.24 seconds
      

1258  
1259  data C9; set C9;
1260  if continuing_cust =0 and lead_year_a =. and target_1 =1 then target_c_switch =1; else
1260! target_c_switch =0;
1261  if continuing_cust =0 and lead_year_a ^=. and target_1 =1 then target_continuing_cust =1;
1261! else target_continuing_cust =0; run;

NOTE: There were 66739 observations read from the data set WORK.C9.
NOTE: The data set WORK.C9 has 66739 observations and 19 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

1262  
1263  proc sort data= C9 out = C9 nodupkey; by cgvkey sgvkey srcdate; run;

NOTE: There were 66739 observations read from the data set WORK.C9.
NOTE: 6 observations with duplicate key values were deleted.
NOTE: The data set WORK.C9 has 66733 observations and 19 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds
      

1264  
1265  data acquirer; set mna_wlinks;
1266  where identity = 'acq'; run;

NOTE: There were 62826 observations read from the data set WORK.MNA_WLINKS.
      WHERE identity='acq';
NOTE: The data set WORK.ACQUIRER has 62826 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.09 seconds
      

1267  
1268  proc sort data = acquirer out = acquirer nodupkey; by gvkey dateann; run;

NOTE: There were 62826 observations read from the data set WORK.ACQUIRER.
NOTE: 288 observations with duplicate key values were deleted.
NOTE: The data set WORK.ACQUIRER has 62538 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.14 seconds
      cpu time            0.15 seconds
      

1269  
1270  proc sql;
1270!           create table C10 as
1271      select a.*,
1272      b.acquirer_d as acquirer_1, b.wanted as wanted_acquirer_1, b.year as ann_year_a,
1273      b.dateann  as dateann_a from C9 as a left join acquirer as b
1274      on a.sgvkey = b.gvkey &
1275      a.srcdate-365 <= b.dateann <= a.srcdate+60
1276      order by a.sgvkey, a.srcdate;
NOTE: Table WORK.C10 created, with 76840 rows and 23 columns.

1277  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.28 seconds
      cpu time            0.31 seconds
      

1278  
1279  
1280  proc sort data= C10 out = C10; by cgvkey sgvkey srcdate descending acquirer_1; run;

NOTE: There were 76840 observations read from the data set WORK.C10.
NOTE: The data set WORK.C10 has 76840 observations and 23 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.09 seconds
      cpu time            0.09 seconds
      

1281  
1282  proc sort data= C10 out = C10 nodupkey; by cgvkey sgvkey srcdate; run;

NOTE: There were 76840 observations read from the data set WORK.C10.
NOTE: 10107 observations with duplicate key values were deleted.
NOTE: The data set WORK.C10 has 66733 observations and 23 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

1283  
1284  data C11; set C10;
1285      if acquirer_1 =. then acquirer_1 =0;
1286      if target_1 =. then target_1 =0;
1287      if wanted_acquirer_1 =. then wanted_acquirer_1 =0;
1288      if wanted_target_1 =. then wanted_target_1 =0;
1289      if continuing_cust =0 and target_continuing_cust = 0 then switch =1; else switch =0;
1290      if continuing_cust =0 and acquirer_1 =1 then acquirer_c_switch =1; else acquirer_c_switch
1290!  =0;
1291      if  r_p_salecs <=10 and p_salecs >= 0.10 and year^= last_year_database;
1292  run;

NOTE: There were 66733 observations read from the data set WORK.C10.
NOTE: The data set WORK.C11 has 38963 observations and 25 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

1293  
1294  
1295  proc sql;
1296          create table C12 as
1297          select *,
1298          sum(switch) as sum_switch
1299          from C11
1300          group by sgvkey, srcdate;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.C12 created, with 38963 rows and 26 columns.

1301  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.09 seconds
      cpu time            0.11 seconds
      

1302  
1303  proc sort data = C12 out = switch_supplier nodupkey; by sgvkey srcdate; run;

NOTE: There were 38963 observations read from the data set WORK.C12.
NOTE: 11601 observations with duplicate key values were deleted.
NOTE: The data set WORK.SWITCH_SUPPLIER has 27362 observations and 26 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
      

1304  
1305  proc sort data = switch_supplier; by wanted_acquirer_1; run;

NOTE: There were 27362 observations read from the data set WORK.SWITCH_SUPPLIER.
NOTE: The data set WORK.SWITCH_SUPPLIER has 27362 observations and 26 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds
      

1306  
1307  data temp.switch_0330_sic3; set switch_supplier; run;

NOTE: There were 27362 observations read from the data set WORK.SWITCH_SUPPLIER.
NOTE: The data set TEMP.SWITCH_0330_SIC3 has 27362 observations and 26 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

1308  
1309  /********************************************************************************************
1309! ****************/
1310  * Create common ownsership shock
1311  /********************************************************************************************
1311! ****************/
1312  
1313  *Get customers and their 3 digit SIC code rivals;
1314  
1315  Libname data '..\..\Data\Datasets';
NOTE: Libref DATA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets
1316  Libname temp '..\..\Data\JAR\temp';
NOTE: Libref TEMP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp
1317  
1318  data C; set data.SC6_sic3;
1319  run;

NOTE: There were 2633520 observations read from the data set DATA.SC6_SIC3.
NOTE: The data set WORK.C has 2633520 observations and 20 variables.
NOTE: DATA statement used (Total process time):
      real time           0.96 seconds
      cpu time            0.78 seconds
      

1320  
1321  proc sort data = data.compa78_20_20220410 (keep = fyear datadate gvkey cusip) out =
1321! comp_cusip nodupkey; by gvkey cusip fyear; run;

NOTE: There were 404385 observations read from the data set DATA.COMPA78_20_20220410.
NOTE: 11 observations with duplicate key values were deleted.
NOTE: The data set WORK.COMP_CUSIP has 404374 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.31 seconds
      cpu time            0.57 seconds
      

1322  
1323  proc sql;
1324      create table C2 as select a.*, b.datadate as cdatadate, b.cusip as ccusip
1325      from C as a left join comp_cusip as b
1326      on a.cgvkey = input(b.gvkey, BEST12.) and a.year = b.fyear
1327      order by a.cgvkey, a.srcdate;
NOTE: Table WORK.C2 created, with 2633520 rows and 22 columns.

1328  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           4.88 seconds
      cpu time            9.03 seconds
      

1329  
1330  
1331  proc sql;
1332      create table C2 as select a.*, b.cusip as rcusip
1333      from C2 as a left join comp_cusip as b
1334      on a.rgvkey = input(b.gvkey, BEST12.) and a.year = b.fyear
1335      order by a.rgvkey, a.year;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.C2 created, with 2633520 rows and 23 columns.

1336  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           4.02 seconds
      cpu time            6.64 seconds
      

1337  
1338  
1339  proc sql;
1340      create table C3_lag as select a.*, b.datadate as cdatadate_lag
1341      from C2 as a left join comp_cusip as b
1342      on a.cgvkey = input(b.gvkey, BEST12.) and b.datadate +365 <=a.cdatadate < b.datadate
1342! +365*2
1343      order by a.cgvkey, a.srcdate;
NOTE: Table WORK.C3_LAG created, with 2637876 rows and 24 columns.

1344  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           8.27 seconds
      cpu time            11.21 seconds
      

1345  
1346  proc sort data = C3_lag out = C3_lag nodupkey; by cgvkey sgvkey srcdate rgvkey; run;

NOTE: There were 2637876 observations read from the data set WORK.C3_LAG.
NOTE: 4356 observations with duplicate key values were deleted.
NOTE: The data set WORK.C3_LAG has 2633520 observations and 24 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           1.38 seconds
      cpu time            2.85 seconds
      

1347  
1348  data C3_lag; set C3_lag;
1349      drop cdatadate;
1350      rename cdatadate_lag = cdatadate;
1351  run;

NOTE: There were 2633520 observations read from the data set WORK.C3_LAG.
NOTE: The data set WORK.C3_LAG has 2633520 observations and 23 variables.
NOTE: DATA statement used (Total process time):
      real time           1.22 seconds
      cpu time            1.00 seconds
      

1352  
1353  proc sql;
1354      create table C3_lag2 as select a.*, b.datadate as cdatadate_lag2
1355      from C2 as a left join comp_cusip as b
1356      on a.cgvkey = input(b.gvkey, BEST12.) and b.datadate +365*2 <=a.cdatadate < b.datadate
1356! +365*3
1357      order by a.cgvkey, a.srcdate;
NOTE: Table WORK.C3_LAG2 created, with 2639288 rows and 24 columns.

1358  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           8.17 seconds
      cpu time            10.89 seconds
      

1359  
1360  proc sort data = C3_lag2 out = C3_lag2 nodupkey; by cgvkey sgvkey srcdate rgvkey; run;

NOTE: There were 2639288 observations read from the data set WORK.C3_LAG2.
NOTE: 5768 observations with duplicate key values were deleted.
NOTE: The data set WORK.C3_LAG2 has 2633520 observations and 24 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           1.60 seconds
      cpu time            3.79 seconds
      

1361  
1362  data C3_lag2; set C3_lag2;
1363      drop cdatadate;
1364      rename cdatadate_lag2 = cdatadate;
1365  run;

NOTE: There were 2633520 observations read from the data set WORK.C3_LAG2.
NOTE: The data set WORK.C3_LAG2 has 2633520 observations and 23 variables.
NOTE: DATA statement used (Total process time):
      real time           1.03 seconds
      cpu time            0.92 seconds
      

1366  
1367  proc sql;
1368      create table C3_lag3 as select a.*, b.datadate as cdatadate_lag3
1369      from C2 as a left join comp_cusip as b
1370      on a.cgvkey = input(b.gvkey, BEST12.) and b.datadate +365*3 <=a.cdatadate < b.datadate
1370! +365*4
1371      order by a.cgvkey, a.srcdate;
NOTE: Table WORK.C3_LAG3 created, with 2642318 rows and 24 columns.

1372  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           8.41 seconds
      cpu time            11.78 seconds
      

1373  
1374  proc sort data = C3_lag3 out = C3_lag3 nodupkey; by cgvkey sgvkey srcdate rgvkey; run;

NOTE: There were 2642318 observations read from the data set WORK.C3_LAG3.
NOTE: 8798 observations with duplicate key values were deleted.
NOTE: The data set WORK.C3_LAG3 has 2633520 observations and 24 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           1.53 seconds
      cpu time            3.48 seconds
      

1375  
1376  data C3_lag3; set C3_lag3;
1377      drop cdatadate;
1378      rename cdatadate_lag3 = cdatadate;
1379  run;

NOTE: There were 2633520 observations read from the data set WORK.C3_LAG3.
NOTE: The data set WORK.C3_LAG3 has 2633520 observations and 23 variables.
NOTE: DATA statement used (Total process time):
      real time           1.21 seconds
      cpu time            1.04 seconds
      

1380  
1381  data C4; set C2 C3_lag C3_lag2 C3_lag3;
1382  run;

NOTE: There were 2633520 observations read from the data set WORK.C2.
NOTE: There were 2633520 observations read from the data set WORK.C3_LAG.
NOTE: There were 2633520 observations read from the data set WORK.C3_LAG2.
NOTE: There were 2633520 observations read from the data set WORK.C3_LAG3.
NOTE: The data set WORK.C4 has 10534080 observations and 23 variables.
NOTE: DATA statement used (Total process time):
      real time           5.21 seconds
      cpu time            3.98 seconds
      

1383  
1384  
1385  *Get institutional block ownership for customer and customer rival;
1386  
1387  data ii5; set data.ii5; run;

NOTE: There were 1479427 observations read from the data set DATA.II5.
NOTE: The data set WORK.II5 has 1479427 observations and 11 variables.
NOTE: DATA statement used (Total process time):
      real time           0.80 seconds
      cpu time            0.76 seconds
      

1388  proc sql;
1389      create table C5 as select a.*, b.mgrno as cmgrno, b.rdate as crdate,
1390      b.instown as cinstown, b.mgrname as cmgrname
1391      from C4 as a left join ii5 as b
1392      on a.cdatadate -365*1.25 <= b.rdate <= a.cdatadate and substr(a.ccusip,1,8) = b.cusip
1393      order by a.ccusip, a.cdatadate;
NOTE: Table WORK.C5 created, with 56950703 rows and 27 columns.

1394  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           3:12.70
      cpu time            3:19.43
      

1395  
1396  proc sort data = C5 out = C6; by srcdate cdatadate descending crdate ccusip rcusip cmgrno;
1396! run;

NOTE: There were 56950703 observations read from the data set WORK.C5.
NOTE: The data set WORK.C6 has 56950703 observations and 27 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           1:40.52
      cpu time            2:15.06
      

1397  proc sort data = C6 out = C6 nodupkey; by srcdate cdatadate ccusip rcusip cmgrno; run;

NOTE: There were 56950703 observations read from the data set WORK.C6.
NOTE: 47047969 observations with duplicate key values were deleted.
NOTE: The data set WORK.C6 has 9902734 observations and 27 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           34.25 seconds
      cpu time            51.56 seconds
      

1398  
1399  data C7; set C6;
1400      where  cmgrname ^=''; run;

NOTE: There were 7931030 observations read from the data set WORK.C6.
      WHERE cmgrname not = ' ';
NOTE: The data set WORK.C7 has 7931030 observations and 27 variables.
NOTE: DATA statement used (Total process time):
      real time           3.42 seconds
      cpu time            3.20 seconds
      

1401  
1402  proc sql;
1403      create table C8 as select a.*, b.mgrno as rmgrno, b.rdate as rrdate,
1404      b.instown as rinstown, b.mgrname as rmgrname
1405      from C7 as a left join ii5 as b
1406      on a.cdatadate -365*1.25 <= b.rdate <= a.cdatadate and substr(a.rcusip,1,8) = b.cusip
1407      order by a.rcusip, a.cdatadate;
NOTE: Table WORK.C8 created, with 48015292 rows and 31 columns.

1408  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           2:35.12
      cpu time            2:33.65
      

1409  
1410  data C9; set C8;
1411      if rmgrname ^= '';
1412  run;

NOTE: There were 48015292 observations read from the data set WORK.C8.
NOTE: The data set WORK.C9 has 43922888 observations and 31 variables.
NOTE: DATA statement used (Total process time):
      real time           46.82 seconds
      cpu time            28.25 seconds
      

1413  
1414  proc sort data = C9 out =C9; by srcdate cdatadate descending rrdate rmgrno rcusip ccusip
1414! crdate cmgrno; run;

NOTE: There were 43922888 observations read from the data set WORK.C9.
NOTE: The data set WORK.C9 has 43922888 observations and 31 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           1:44.41
      cpu time            2:14.45
      

1415  proc sort data = C9 out = C10 nodupkey; by srcdate cdatadate rmgrno rcusip ccusip crdate
1415! cmgrno; run;

NOTE: There were 43922888 observations read from the data set WORK.C9.
NOTE: 30057284 observations with duplicate key values were deleted.
NOTE: The data set WORK.C10 has 13865604 observations and 31 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           56.98 seconds
      cpu time            1:18.92
      

1416  
1417  
1418  *construct financial institution merger sample relevant for our sample using the ones listed
1418! in He and Huang Appendix;
1419  
1420  data C10; set C10;
1421      cmgrname2 = LOWCASE(cmgrname);
1422      rmgrname2 = LOWCASE(rmgrname);
1423      drop cmgrname rmgrname;
1424      rename cmgrname2 = cmgrname rmgrname2 = rmgrname;
1425  run;

NOTE: There were 13865604 observations read from the data set WORK.C10.
NOTE: The data set WORK.C10 has 13865604 observations and 31 variables.
NOTE: DATA statement used (Total process time):
      real time           16.36 seconds
      cpu time            11.32 seconds
      

1426  
1427  proc sort data =C10 out = match_nm nodupkey; by cmgrname rmgrname; run;

NOTE: There were 13865604 observations read from the data set WORK.C10.
NOTE: 13324155 observations with duplicate key values were deleted.
NOTE: The data set WORK.MATCH_NM has 541449 observations and 31 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           12.78 seconds
      cpu time            20.26 seconds
      

1428  
1429  data match_nm; set match_nm;
1430  drop crdate srcdate; run;

NOTE: There were 541449 observations read from the data set WORK.MATCH_NM.
NOTE: The data set WORK.MATCH_NM has 541449 observations and 29 variables.
NOTE: DATA statement used (Total process time):
      real time           0.38 seconds
      cpu time            0.28 seconds
      

1431  
1432  proc import datafile="..\..\Data\Datasets\Fin_mna_20221219.csv"
1433          out= all_fin_mna dbms=csv replace;
1434      getnames=yes;
1435  run;

1436   /**********************************************************************
1437   *   PRODUCT:   SAS
1438   *   VERSION:   9.4
1439   *   CREATOR:   External File Interface
1440   *   DATE:      24JUL24
1441   *   DESC:      Generated SAS Datastep Code
1442   *   TEMPLATE SOURCE:  (None Specified.)
1443   ***********************************************************************/
1444      data WORK.ALL_FIN_MNA    ;
1445      %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
1446      infile '..\..\Data\Datasets\Fin_mna_20221219.csv' delimiter = ',' MISSOVER DSD
1446! lrecl=32767 firstobs=2 ;
1447         informat Acquiror_Name $32. ;
1448         informat Target_Name $31. ;
1449         informat Acquirer_Mgrno best32. ;
1450         informat Target_Mgrno best32. ;
1451         informat Announcement_Date mmddyy10. ;
1452         informat Completion_Date mmddyy10. ;
1453         format Acquiror_Name $32. ;
1454         format Target_Name $31. ;
1455         format Acquirer_Mgrno best12. ;
1456         format Target_Mgrno best12. ;
1457         format Announcement_Date mmddyy10. ;
1458         format Completion_Date mmddyy10. ;
1459      input
1460                  Acquiror_Name  $
1461                  Target_Name  $
1462                  Acquirer_Mgrno
1463                  Target_Mgrno
1464                  Announcement_Date
1465                  Completion_Date
1466      ;
1467      if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
1468      run;

NOTE: The infile '..\..\Data\Datasets\Fin_mna_20221219.csv' is:
      Filename=C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets\Fin_mna_20221219.csv,
      RECFM=V,LRECL=32767,File Size (bytes)=5482,
      Last Modified=20Dec2022:01:58:56,
      Create Time=25May2024:20:00:46

NOTE: 64 records were read from the infile '..\..\Data\Datasets\Fin_mna_20221219.csv'.
      The minimum record length was 56.
      The maximum record length was 96.
NOTE: The data set WORK.ALL_FIN_MNA has 64 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

64 rows created in WORK.ALL_FIN_MNA from ..\..\Data\Datasets\Fin_mna_20221219.csv.
  
  
  
NOTE: WORK.ALL_FIN_MNA data set was successfully created.
NOTE: The data set WORK.ALL_FIN_MNA has 64 observations and 6 variables.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.29 seconds
      cpu time            0.11 seconds
      

1469  
1470  
1471  data tar ;
1472      set all_fin_mna;
1473      rename Target_Name = holding_fin_name  Acquiror_Name = incoming_fin_name Target_Mgrno =
1473! holding_fin_mgrno
1474      Acquirer_Mgrno = incoming_fin_mgrno Announcement_Date = announcement_date;
1475      identity = 'tar';
1476  run;

NOTE: There were 64 observations read from the data set WORK.ALL_FIN_MNA.
NOTE: The data set WORK.TAR has 64 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1477  
1478  data acq ;
1479      set all_fin_mna;
1480      rename Acquiror_Name = holding_fin_name  Target_Name = incoming_fin_name Acquirer_Mgrno =
1480!  holding_fin_mgrno
1481      Target_Mgrno = incoming_fin_mgrno Announcement_Date = announcement_date;
1482      identity = 'acq';
1483  run;

NOTE: There were 64 observations read from the data set WORK.ALL_FIN_MNA.
NOTE: The data set WORK.ACQ has 64 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

1484  
1485  data fin_mna; set tar acq ;
1486      merger =1;
1487  run;

WARNING: Multiple lengths were specified for the variable holding_fin_name by input data set(s). 
         This can cause truncation of data.
NOTE: There were 64 observations read from the data set WORK.TAR.
NOTE: There were 64 observations read from the data set WORK.ACQ.
NOTE: The data set WORK.FIN_MNA has 128 observations and 8 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

1488  
1489  proc sql;
1490      create table C11 as select a.*, b.holding_fin_mgrno, b.holding_fin_name,
1490! b.Completion_Date, b.announcement_date
1491      from C10 as a left join fin_mna as b
1492      on a.cmgrno = b.holding_fin_mgrno  and
1493      b.announcement_date -365*4 <= a.crdate < b.announcement_date
1494      order by a.cmgrno, a.crdate;
NOTE: Table WORK.C11 created, with 14068695 rows and 35 columns.

1495  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           59.15 seconds
      cpu time            1:14.99
      

1496  
1497  proc sql;
1498      create table C12 as select a.*, b.holding_fin_mgrno as holding_fin_mgrno_1,
1498! b.incoming_fin_name, b.incoming_fin_mgrno, b.merger
1499      from C11 as a left join fin_mna as b
1500      on a.cmgrno = b.holding_fin_mgrno and a.rmgrno = b.incoming_fin_mgrno and
1501      b.announcement_date -365*4 <= a.crdate < b.announcement_date and
1502      b.announcement_date -365*4 <= a.rrdate < b.announcement_date
1503      order by a.cmgrno, a.rmgrno, a.crdate, a.rrdate;
NOTE: Table WORK.C12 created, with 14068705 rows and 39 columns.

1504  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1:14.91
      cpu time            1:29.23
      

1505  
1506  data temp; set C12;
1507  where merger^= .; run;

NOTE: There were 2505 observations read from the data set WORK.C12.
      WHERE merger not = .;
NOTE: The data set WORK.TEMP has 2505 observations and 39 variables.
NOTE: DATA statement used (Total process time):
      real time           8.63 seconds
      cpu time            4.95 seconds
      

1508  
1509  proc sort data = temp nodupkey; by crdate incoming_fin_mgrno; run;

NOTE: There were 2505 observations read from the data set WORK.TEMP.
NOTE: 2333 observations with duplicate key values were deleted.
NOTE: The data set WORK.TEMP has 172 observations and 39 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
      

1510  proc sql;
1511      create table C13 as select a.*, b.incoming_fin_mgrno as customerheldby_incoming_mgrno
1512      from C12 as a left join temp as b
1513      on a.cmgrno = b.incoming_fin_mgrno and
1514      a.crdate = b.crdate
1515      order by a.cmgrno, a.crdate;
NOTE: Table WORK.C13 created, with 14068705 rows and 40 columns.

1516  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1:03.82
      cpu time            58.06 seconds
      

1517  
1518  
1519  data C14; set C13;
1520      if merger =1 and customerheldby_incoming_mgrno =. then treat =1;
1521      if merger =. and holding_fin_mgrno ^= . then treat =0;
1522  run;

NOTE: There were 14068705 observations read from the data set WORK.C13.
NOTE: The data set WORK.C14 has 14068705 observations and 41 variables.
NOTE: DATA statement used (Total process time):
      real time           15.89 seconds
      cpu time            9.37 seconds
      

1523  
1524  data C15; set C14;
1525      if treat ^=.;
1526  run;

NOTE: There were 14068705 observations read from the data set WORK.C14.
NOTE: The data set WORK.C15 has 898887 observations and 41 variables.
NOTE: DATA statement used (Total process time):
      real time           7.02 seconds
      cpu time            3.82 seconds
      

1527  
1528  proc sort data = C15 out = C15; by sgvkey cgvkey rgvkey descending treat announcement_date;
1528! run;

NOTE: There were 898887 observations read from the data set WORK.C15.
NOTE: The data set WORK.C15 has 898887 observations and 41 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           2.02 seconds
      cpu time            2.90 seconds
      

1529  proc sort data = C15 out = C16 nodupkey; by sgvkey cgvkey rgvkey treat announcement_date; run
1529! ;

NOTE: There were 898887 observations read from the data set WORK.C15.
NOTE: 782153 observations with duplicate key values were deleted.
NOTE: The data set WORK.C16 has 116734 observations and 41 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.92 seconds
      cpu time            1.46 seconds
      
1530  data check; set C16;
1531      if treat =1;
1532  run;

NOTE: There were 116734 observations read from the data set WORK.C16.
NOTE: The data set WORK.CHECK has 635 observations and 41 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.04 seconds
      

1533  
1534  proc sql;
1535          create table C17 as
1536          select *,
1537          sum(treat) as cust_treat, avg(treat) as cust_treat2, avg(treat*cinstown) as
1537! cust_treat3
1538          from C16
1539          group by sgvkey, announcement_date;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.C17 created, with 116734 rows and 44 columns.

1540  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.38 seconds
      cpu time            0.42 seconds
      

1541  
1542  data C18; set C17;
1543  if year(announcement_date) ^= 2008;
1544  
1545  

NOTE: There were 116734 observations read from the data set WORK.C17.
NOTE: The data set WORK.C18 has 81505 observations and 44 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1546  proc sort data = C18 out = temp.CO_shock_20221220 nodupkey; by sgvkey announcement_date; run;

NOTE: There were 81505 observations read from the data set WORK.C18.
NOTE: 78126 observations with duplicate key values were deleted.
NOTE: The data set TEMP.CO_SHOCK_20221220 has 3379 observations and 44 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.07 seconds
      

1547  
1548  /********************************************************************************************
1548! **********************************************************/
1549  /* Create RSI- JV and Alliances
1550  /********************************************************************************************
1550! **********************************************************/
1551  
1552  
1553  Libname data '..\..\Data\Datasets';
NOTE: Libref DATA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets
1554  Libname temp '..\..\Data\JAR\temp';
NOTE: Libref TEMP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp
1555  
1556  
1557  proc sort data = data.seg20221120 out= Ctmp; by cgvkey srcdate; run;

NOTE: There were 67342 observations read from the data set DATA.SEG20221120.
NOTE: The data set WORK.CTMP has 67342 observations and 26 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.13 seconds
      cpu time            0.09 seconds
      

1558  
1559  data CTMP; set CTMP;
1560  run;

NOTE: There were 67342 observations read from the data set WORK.CTMP.
NOTE: The data set WORK.CTMP has 67342 observations and 26 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.06 seconds
      

1561  
1562  
1563  proc sort data = data.compa78_20_20220410 out = comp nodupkey; by gvkey fyear; run;

NOTE: There were 404385 observations read from the data set DATA.COMPA78_20_20220410.
NOTE: 11 observations with duplicate key values were deleted.
NOTE: The data set WORK.COMP has 404374 observations and 63 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.61 seconds
      cpu time            0.76 seconds
      

1564  
1565  proc sql;
1566      create table CTMP as select a.*, b.sic1 as csic1, b.naics as cnaics, b.naics3 as cnaics3,
1566!  b.siccd as csiccd,
1567      b.at as cat, b.sale as csale, b.ib as cib
1568      from CTMP as a left join comp as b
1569      on a.cgvkey = input(b.gvkey, BEST12.) and a.year= b.fyear
1570      order by gvkey, fyear;
NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.CTMP created, with 67342 rows and 33 columns.

1571  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.75 seconds
      cpu time            1.04 seconds
      

1572  
1573  proc sql;
1574      create table CTMP as select a.*, b.sic1, b.naics, b.naics3, b.siccd
1575      from CTMP as a left join comp as b
1576      on a.sgvkey = input(b.gvkey, BEST12.) and a.year= b.fyear
1577      order by gvkey, fyear;
NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.CTMP created, with 67342 rows and 37 columns.

1578  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.94 seconds
      cpu time            1.28 seconds
      

1579  
1580  data CTMP; set CTMP;
1581       cnaics1 = input(cnaics, BEST12.);
1582       csiccd1 = input(csiccd, BEST12.);
1583       csic3 = int(csic1)/10;
1584       csiccd3= int(csiccd1)/10;
1585       csiccd2= int(csiccd1)/100;
1586       naics1 = input(naics, BEST12.);
1587       siccd1 = input(siccd, BEST12.);
1588       sic3 = int(sic1)/10;
1589       siccd3= int(siccd1)/10;
1590       siccd2= int(siccd1)/100;
1591       drop cnaics csiccd naics siccd;
1592  run;

NOTE: Numeric values have been converted to character values at the places given by: 
      (Line):(Column).
      1582:22   1587:21   
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      4345 at 1583:14    4345 at 1583:24    10716 at 1584:15   10716 at 1584:27
      10716 at 1585:15   10716 at 1585:27   473 at 1588:13     473 at 1588:22
      16584 at 1589:14   16584 at 1589:25   16584 at 1590:14   16584 at 1590:25
NOTE: There were 67342 observations read from the data set WORK.CTMP.
NOTE: The data set WORK.CTMP has 67342 observations and 43 variables.
NOTE: DATA statement used (Total process time):
      real time           0.12 seconds
      cpu time            0.12 seconds
      

1593  
1594  PROC IMPORT OUT= WORK.jv_alliance_allyear DATAFILE=
1594! '..\..\Data\Datasets\jv_alliance_allyear.dta'
1595     DBMS=dta REPLACE;
1596  RUN;

NOTE: One or more variables were converted because the data type is not supported by the V9 
      engine. For more details, run with options MSGLEVEL=I.
NOTE: The import data set has 190704 observations and 23 variables.
NOTE: WORK.JV_ALLIANCE_ALLYEAR data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.73 seconds
      cpu time            0.23 seconds
      

1597  
1598  
1599  %macro doit;
1600  
1601        %do i = 3 %to 21;
1602          data temp&i. (keep = CUSIP1 CUSIP2 begin_year end_year);
1603              set jv_alliance_allyear;
1604              where CUSIP&i. ^= '';
1605              drop CUSIP2;
1606              rename CUSIP&i. = CUSIP2;
1607        %end;
1608    run;
1609  %mend doit;
1610  %doit

NOTE: There were 18624 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP3 not = ' ';
NOTE: The data set WORK.TEMP3 has 18624 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.04 seconds
      


NOTE: There were 4944 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP4 not = ' ';
NOTE: The data set WORK.TEMP4 has 4944 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      


NOTE: There were 1948 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP5 not = ' ';
NOTE: The data set WORK.TEMP5 has 1948 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      


NOTE: There were 915 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP6 not = ' ';
NOTE: The data set WORK.TEMP6 has 915 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      


NOTE: There were 501 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP7 not = ' ';
NOTE: The data set WORK.TEMP7 has 501 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      


NOTE: There were 294 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP8 not = ' ';
NOTE: The data set WORK.TEMP8 has 294 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      


NOTE: There were 189 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP9 not = ' ';
NOTE: The data set WORK.TEMP9 has 189 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      


NOTE: There were 113 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP10 not = ' ';
NOTE: The data set WORK.TEMP10 has 113 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      


NOTE: There were 78 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP11 not = ' ';
NOTE: The data set WORK.TEMP11 has 78 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.04 seconds
      


NOTE: There were 53 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP12 not = ' ';
NOTE: The data set WORK.TEMP12 has 53 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      


NOTE: There were 35 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP13 not = ' ';
NOTE: The data set WORK.TEMP13 has 35 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      


NOTE: There were 23 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP14 not = ' ';
NOTE: The data set WORK.TEMP14 has 23 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      


NOTE: There were 15 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP15 not = ' ';
NOTE: The data set WORK.TEMP15 has 15 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      


NOTE: There were 11 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP16 not = ' ';
NOTE: The data set WORK.TEMP16 has 11 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      


NOTE: There were 6 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP17 not = ' ';
NOTE: The data set WORK.TEMP17 has 6 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      


NOTE: There were 5 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP18 not = ' ';
NOTE: The data set WORK.TEMP18 has 5 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      


NOTE: There were 4 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP19 not = ' ';
NOTE: The data set WORK.TEMP19 has 4 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      


NOTE: There were 2 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP20 not = ' ';
NOTE: The data set WORK.TEMP20 has 2 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      


NOTE: There were 1 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP21 not = ' ';
NOTE: The data set WORK.TEMP21 has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.04 seconds
      

1611  
1612  data temp2 (keep = CUSIP1 CUSIP2 begin_year end_year);
1613        set jv_alliance_allyear;
1614      where CUSIP2 ^= '';
1615  run;

NOTE: There were 190704 observations read from the data set WORK.JV_ALLIANCE_ALLYEAR.
      WHERE CUSIP2 not = ' ';
NOTE: The data set WORK.TEMP2 has 190704 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.09 seconds
      

1616  data all; set temp2 temp3 temp4 temp5 temp6 temp7 temp8 temp9 temp10 temp11 temp12
1617      temp13 temp14 temp15 temp16 temp17 temp18 temp19 temp20 temp21;
1618  run;

NOTE: There were 190704 observations read from the data set WORK.TEMP2.
NOTE: There were 18624 observations read from the data set WORK.TEMP3.
NOTE: There were 4944 observations read from the data set WORK.TEMP4.
NOTE: There were 1948 observations read from the data set WORK.TEMP5.
NOTE: There were 915 observations read from the data set WORK.TEMP6.
NOTE: There were 501 observations read from the data set WORK.TEMP7.
NOTE: There were 294 observations read from the data set WORK.TEMP8.
NOTE: There were 189 observations read from the data set WORK.TEMP9.
NOTE: There were 113 observations read from the data set WORK.TEMP10.
NOTE: There were 78 observations read from the data set WORK.TEMP11.
NOTE: There were 53 observations read from the data set WORK.TEMP12.
NOTE: There were 35 observations read from the data set WORK.TEMP13.
NOTE: There were 23 observations read from the data set WORK.TEMP14.
NOTE: There were 15 observations read from the data set WORK.TEMP15.
NOTE: There were 11 observations read from the data set WORK.TEMP16.
NOTE: There were 6 observations read from the data set WORK.TEMP17.
NOTE: There were 5 observations read from the data set WORK.TEMP18.
NOTE: There were 4 observations read from the data set WORK.TEMP19.
NOTE: There were 2 observations read from the data set WORK.TEMP20.
NOTE: There were 1 observations read from the data set WORK.TEMP21.
NOTE: The data set WORK.ALL has 218465 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
      

1619  
1620  data reverse; set all;
1621      rename CUSIP2 = CUSIP_temp;
1622      rename CUSIP1 = CUSIP2;

NOTE: There were 218465 observations read from the data set WORK.ALL.
NOTE: The data set WORK.REVERSE has 218465 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.04 seconds
      

1623  data reverse; set reverse;
1624      rename CUSIP_temp = CUSIP1;
1625  run;

NOTE: There were 218465 observations read from the data set WORK.REVERSE.
NOTE: The data set WORK.REVERSE has 218465 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds
      

1626  
1627  data all_pairs; set all reverse; run;

NOTE: There were 218465 observations read from the data set WORK.ALL.
NOTE: There were 218465 observations read from the data set WORK.REVERSE.
NOTE: The data set WORK.ALL_PAIRS has 436930 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

1628  
1629  proc sort data = all_pairs out = all_pairs nodupkey; by CUSIP1 CUSIP2 begin_year; run;

NOTE: There were 436930 observations read from the data set WORK.ALL_PAIRS.
NOTE: 4594 observations with duplicate key values were deleted.
NOTE: The data set WORK.ALL_PAIRS has 432336 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.20 seconds
      cpu time            0.45 seconds
      

1630  
1631  data CTMP; set CTMP;
1632      SCUSIP6 = substr(SCUSIP,1,6);
1633      CCUSIP6 = substr(CCUSIP,1,6);
1634  run;

NOTE: There were 67342 observations read from the data set WORK.CTMP.
NOTE: The data set WORK.CTMP has 67342 observations and 45 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

1635  
1636  proc sort data = CTMP out = CTMP nodupkey; by SCUSIP6 CCUSIP6 year; run;

NOTE: There were 67342 observations read from the data set WORK.CTMP.
NOTE: 76 observations with duplicate key values were deleted.
NOTE: The data set WORK.CTMP has 67266 observations and 45 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.13 seconds
      cpu time            0.14 seconds
      

1637  
1638  proc sql;
1639    create table Ctmp2 as
1640      select a.*, b.begin_year as jv_start_year_0, c.begin_year as jv_start_year_1,
1640! d.begin_year as jv_start_year_2,
1641      e.begin_year as jv_start_year_3
1642      , f.begin_year as jv_start_year_4, g.begin_year as jv_start_year_5, h.begin_year as
1642! jv_start_year_6
1643      , i.begin_year as jv_start_year_7
1644      from Ctmp a
1645      left join all_pairs b
1646      on substr(a.SCUSIP,1,6)= b.CUSIP2 and substr(a.CCUSIP,1,6) = b.CUSIP1 and a.year =
1646! b.begin_year
1647      left join all_pairs c
1648      on substr(a.SCUSIP,1,6)= c.CUSIP2 and substr(a.CCUSIP,1,6) = c.CUSIP1 and a.year-1 =
1648! c.begin_year
1649      left join all_pairs d
1650      on substr(a.SCUSIP,1,6)= d.CUSIP2 and substr(a.CCUSIP,1,6) = d.CUSIP1 and a.year-2 =
1650! d.begin_year
1651      left join all_pairs e
1652      on substr(a.SCUSIP,1,6)= e.CUSIP2 and substr(a.CCUSIP,1,6) = e.CUSIP1 and a.year -3 =
1652! e.begin_year
1653      left join all_pairs f
1654      on substr(a.SCUSIP,1,6)= f.CUSIP2 and substr(a.CCUSIP,1,6) = f.CUSIP1 and a.year-4 =
1654! f.begin_year
1655      left join all_pairs g
1656      on substr(a.SCUSIP,1,6)= g.CUSIP2 and substr(a.CCUSIP,1,6) = g.CUSIP1 and a.year-5 =
1656! g.begin_year
1657      left join all_pairs h
1658      on substr(a.SCUSIP,1,6)= h.CUSIP2 and substr(a.CCUSIP,1,6) = h.CUSIP1 and a.year-6 =
1658! h.begin_year
1659      left join all_pairs i
1660      on substr(a.SCUSIP,1,6)= i.CUSIP2 and substr(a.CCUSIP,1,6) = i.CUSIP1 and a.year-7 =
1660! i.begin_year;
NOTE: Table WORK.CTMP2 created, with 67266 rows and 53 columns.

1661  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           2.99 seconds
      cpu time            4.96 seconds
      

1662  
1663  data CTMP2; set CTMP2;
1664      if jv_start_year_0 ^=. then jv_flag_0 =1; else jv_flag_0 =0;
1665      if jv_start_year_1 ^=. then jv_flag_1 =1; else jv_flag_1 =0;
1666      if jv_start_year_2 ^=. then jv_flag_2 =1; else jv_flag_2 =0;
1667      if jv_start_year_3 ^=. then jv_flag_3 =1; else jv_flag_3 =0;
1668      if jv_start_year_4 ^=. then jv_flag_4 =1; else jv_flag_4 =0;
1669      if jv_start_year_5 ^=. then jv_flag_5 =1; else jv_flag_5 =0;
1670      if jv_start_year_6 ^=. then jv_flag_6 =1; else jv_flag_6 =0;
1671      if jv_start_year_7 ^=. then jv_flag_7 =1; else jv_flag_7 =0;
1672  
1673  run;

NOTE: There were 67266 observations read from the data set WORK.CTMP2.
NOTE: The data set WORK.CTMP2 has 67266 observations and 61 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1674  
1675  data CTMP2; set CTMP2;
1676      jv_sum_07 = jv_flag_0 + jv_flag_1+ jv_flag_2+ jv_flag_3+ jv_flag_4+ jv_flag_5+ jv_flag_6
1676! + jv_flag_7;
1677      run;

NOTE: There were 67266 observations read from the data set WORK.CTMP2.
NOTE: The data set WORK.CTMP2 has 67266 observations and 62 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1678  
1679  proc sql;
1679!           create table CTMP3 as
1680      select *,
1681      (jv_sum_07-mean(jv_sum_07)) as adj_jv_sum_07csic3
1682      from CTMP2
1683      group by csic3, year;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.CTMP3 created, with 67266 rows and 63 columns.

1684  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.30 seconds
      cpu time            0.31 seconds
      

1685  
1686     proc sql;
1686!              create table CTMP4 as
1687      select *,
1688      (sum(csale*adj_jv_sum_07csic3)/sum(csale)) as csale_wavg_adj_jv_sum_07csic3
1689      from CTMP3
1690      group by sgvkey, year;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.CTMP4 created, with 67266 rows and 64 columns.

1691  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.34 seconds
      cpu time            0.46 seconds
      

1692  
1693  data temp.RSI_JValliances; set CTMP4;
1694  run;

NOTE: There were 67266 observations read from the data set WORK.CTMP4.
NOTE: The data set TEMP.RSI_JVALLIANCES has 67266 observations and 64 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.06 seconds
      

1695  
1696  proc export data=temp.RSI_JValliances
1697      outfile="..\..\Data\JAR\temp\RSI_JValliances.dta"
1698      DBMS= dta REPLACE;
1699  run;

NOTE: The export data set has 67266 observations and 64 variables.
NOTE: "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp\RSI_JValliances.dta" file was 
      successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           0.25 seconds
      cpu time            0.23 seconds
      

1700  
1701  
1702  
1703  
1704  /********************************************************************************************
1704! **********************************************************/
1705  /* Create RSI- relationship tenure.sas
1706  /********************************************************************************************
1706! **********************************************************/
1707  Libname data '..\..\Data\Datasets';
NOTE: Libref DATA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets
1708  Libname temp '..\..\Data\JAR\temp';
NOTE: Libref TEMP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp
1709  
1710  data CTMP; set CTMP;
1711  run;

NOTE: There were 67266 observations read from the data set WORK.CTMP.
NOTE: The data set WORK.CTMP has 67266 observations and 45 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.09 seconds
      

1712  
1713  proc sort data = data.compa78_20_20220410 out = comp nodupkey; by gvkey fyear; run;

NOTE: There were 404385 observations read from the data set DATA.COMPA78_20_20220410.
NOTE: 11 observations with duplicate key values were deleted.
NOTE: The data set WORK.COMP has 404374 observations and 63 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.60 seconds
      cpu time            0.85 seconds
      

1714  
1715  proc sql;
1716      create table CTMP as select a.*, b.sic1 as csic1, b.naics as cnaics, b.naics3 as cnaics3,
1716!  b.siccd as csiccd,
1717      b.at as cat, b.sale as csale, b.ib as cib
1718      from CTMP as a left join comp as b
1719      on a.cgvkey = input(b.gvkey, BEST12.) and a.year= b.fyear
1720      order by gvkey, fyear;
NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable csic1 already exists on file WORK.CTMP.
WARNING: Variable cnaics3 already exists on file WORK.CTMP.
WARNING: Variable cat already exists on file WORK.CTMP.
WARNING: Variable csale already exists on file WORK.CTMP.
WARNING: Variable cib already exists on file WORK.CTMP.
NOTE: Table WORK.CTMP created, with 67266 rows and 47 columns.

1721  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.96 seconds
      cpu time            1.37 seconds
      

1722  
1723  data segcust76_19; set data.segcust76_19;
1724          if cnms = '' then delete;
1725  run;

NOTE: There were 579187 observations read from the data set DATA.SEGCUST76_19.
NOTE: The data set WORK.SEGCUST76_19 has 551236 observations and 11 variables.
NOTE: DATA statement used (Total process time):
      real time           0.30 seconds
      cpu time            0.26 seconds
      

1726  
1727  data segcust76_19;
1728  set segcust76_19;
1729          No_name =findw(strip(cnms), "Customers",' ') or findw(strip(cnms), "customers",' ')
1730          or findw(strip(cnms), "Customer",' ') or findw(strip(cnms), "customer",' ') or
1730! findw(strip(cnms), "CUSTOMERS",' ')
1731          or findw(strip(cnms), "Not Reported",' ') or findw(strip(cnms), "Not reported",' ')
1731! or findw(strip(cnms), "Not Repported",' ')
1732          or findw(strip(cnms), "NOT REPORTED",' ');
1733          if No_name ^=0 then delete;
1734  run;

NOTE: There were 551236 observations read from the data set WORK.SEGCUST76_19.
NOTE: The data set WORK.SEGCUST76_19 has 419837 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.85 seconds
      cpu time            0.85 seconds
      

1735  
1736  proc sql;
1737          create table segcust76_19 as
1738          select *, sum(salecs) as total_salecs
1739          from segcust76_19
1740          group by gvkey,cnms, year;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.SEGCUST76_19 created, with 419837 rows and 13 columns.

1741  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.46 seconds
      cpu time            0.67 seconds
      

1742  
1743  proc sort data = segcust76_19 out = segcust76_19 nodupkey;
1744    by  gvkey cnms year;
1745  run;

NOTE: There were 419837 observations read from the data set WORK.SEGCUST76_19.
NOTE: 34419 observations with duplicate key values were deleted.
NOTE: The data set WORK.SEGCUST76_19 has 385418 observations and 13 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.19 seconds
      cpu time            0.46 seconds
      

1746  
1747  data link; set data.seglink;
1748          year = year(srcdate);
1749          where 1976<=year(srcdate) <=2019;
1750  run;

NOTE: There were 109503 observations read from the data set DATA.SEGLINK.
      WHERE (1976<=YEAR(srcdate)) and (YEAR(srcdate)<=2019);
NOTE: The data set WORK.LINK has 109503 observations and 15 variables.
NOTE: DATA statement used (Total process time):
      real time           0.17 seconds
      cpu time            0.17 seconds
      

1751  
1752  proc sort data=link out =tmp nodupkey; by gvkey cid year; run;

NOTE: There were 109503 observations read from the data set WORK.LINK.
NOTE: 99 observations with duplicate key values were deleted.
NOTE: The data set WORK.TMP has 109404 observations and 15 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.15 seconds
      cpu time            0.12 seconds
      

1753  
1754  proc sql;
1755    create table seg2 as
1756      select a.*, b.CGVKEY, b.CTIC, b.CCUSIP, b.CCONM, b.CNMS as CCNMS, b.CID as CCID, b.gvkey,
1756!  b.SCUSIP
1757      from segcust76_19 a
1758          left join tmp b on a.CID =b.CID and a.gvkey =b.gvkey and a.srcdate = b.srcdate
1759          order by a.gvkey, a.cid, a.srcdate;
WARNING: Variable GVKEY already exists on file WORK.SEG2.
NOTE: Table WORK.SEG2 created, with 385418 rows and 20 columns.

1760  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.81 seconds
      cpu time            1.34 seconds
      

1761  
1762  data seg2; set seg2;
1763          if cgvkey = '' and ctype = 'COMPANY' then cgvkey = '10000001';
1764          if ctype in('GOVDOM', 'GOVERN', 'MARKET', 'GEOREG', 'GOVFRN', 'GOVSTATE', 'GOVLOC')
1764! then cgvkey = '10000003';
1765  run;

NOTE: There were 385418 observations read from the data set WORK.SEG2.
NOTE: The data set WORK.SEG2 has 385418 observations and 20 variables.
NOTE: DATA statement used (Total process time):
      real time           0.23 seconds
      cpu time            0.21 seconds
      

1766  
1767  data seg3; set seg2;
1768          where cgvkey not in ('','10000001','10000003')
1769          and gvkey not in ('') and year not in (.);
1770  run;

NOTE: There were 107579 observations read from the data set WORK.SEG2.
      WHERE cgvkey not in (' ', '10000001', '10000003') and (gvkey not = ' ') and (year not = .);
NOTE: The data set WORK.SEG3 has 107579 observations and 20 variables.
NOTE: DATA statement used (Total process time):
      real time           0.13 seconds
      cpu time            0.12 seconds
      

1771  
1772  data seg4; set seg3;
1773          cgvkey1 = input(cgvkey, 8.);
1774          sgvkey = input(gvkey, 8.);
1775          drop cgvkey gvkey salecs cid ccid gareac gareat sid No_name;
1776          rename cgvkey1 = cgvkey;
1777  run;

NOTE: There were 107579 observations read from the data set WORK.SEG3.
NOTE: The data set WORK.SEG4 has 107579 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1778  proc sort data = seg4 (keep = sgvkey cgvkey year) out =seg4; by sgvkey cgvkey year; run;

NOTE: There were 107579 observations read from the data set WORK.SEG4.
NOTE: The data set WORK.SEG4 has 107579 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.09 seconds
      cpu time            0.09 seconds
      

1779  proc sort data = seg4 (keep = sgvkey cgvkey year) out =seg5 nodupkey; by sgvkey cgvkey; run;

NOTE: There were 107579 observations read from the data set WORK.SEG4.
NOTE: 77132 observations with duplicate key values were deleted.
NOTE: The data set WORK.SEG5 has 30447 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.07 seconds
      

1780  
1781  proc sql;
1781!           create table CTMP2 as
1782      select a.*,
1783      b.year as first_year_rt from CTMP as a left join seg5 as b
1784      on a.sgvkey = b.sgvkey and a.cgvkey = b.cgvkey
1785      order by a.sgvkey, a.cgvkey, a.year;
NOTE: Table WORK.CTMP2 created, with 67266 rows and 48 columns.

1786  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.31 seconds
      cpu time            0.45 seconds
      

1787  
1788  data CTMP3; set CTMP2;
1789      rt = year - first_year_rt;
1790  run;

NOTE: There were 67266 observations read from the data set WORK.CTMP2.
NOTE: The data set WORK.CTMP3 has 67266 observations and 49 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.06 seconds
      

1791  
1792  
1793  proc sql;
1793!           create table CTMP4 as
1794      select *,
1795      (sum(csale*rt)/sum(csale)) as csale_wavg_rt
1796      from CTMP3
1797      group by sgvkey, year;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.CTMP4 created, with 67266 rows and 50 columns.

1798  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.29 seconds
      cpu time            0.35 seconds
      

1799  
1800  data temp.RSI_relationtenure; set CTMP4;
1801  run;

NOTE: There were 67266 observations read from the data set WORK.CTMP4.
NOTE: The data set TEMP.RSI_RELATIONTENURE has 67266 observations and 50 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.06 seconds
      

1802  
1803  proc export data=CTMP4
1804      outfile="..\..\Data\JAR\temp\RSI_relationtenure.dta"
1805      DBMS= dta REPLACE;
1806  run;

NOTE: The export data set has 67266 observations and 50 variables.
NOTE: "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp\RSI_relationtenure.dta" file 
      was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           0.14 seconds
      cpu time            0.14 seconds
      

1807  
1808  *********************************************************************************************
1808! *********************************************************/
1809  /* Merge in common ownership, customer switch, M&A data;
1810  /********************************************************************************************
1810! **********************************************************/
1811  Libname data '..\..\Data\Datasets';
NOTE: Libref DATA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets
1812  Libname temp '..\..\Data\JAR\temp';
NOTE: Libref TEMP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp
1813  
1814  
1815  /*Merge customer switch dataset*/
1816  
1817  proc sql;
1818    create table supplier_year_xvar_controls_2 as
1819      select a.*,  b.acquirer_1 as acquirer_1x, b.target_1 as target_1x
1820      from temp.S_20221217 a
1821      left join data.switch_0330 b
1822      on a.sgvkey = b.sgvkey and a.srcdate = b.srcdate;
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_2 created, with 36162 rows and 69 columns.

1823  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.37 seconds
      cpu time            0.20 seconds
      

1824  
1825  proc sql;
1826    create table supplier_year_xvar_controls_2 as
1827      select a.*, b.sum_switch as sum_switch_sic3, b.wanted_acquirer_1 as
1827! wanted_acquirer_1_sic3, b.wanted_target_1 as wanted_target_1_sic3,
1828      b.acquirer_1 as acquirer_1x_sic3, b.target_1 as target_1x_sic3
1829      from supplier_year_xvar_controls_2 a
1830      left join data.switch_0330_sic3 b
1831      on a.sgvkey = b.sgvkey and a.srcdate = b.srcdate;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_2 created, with 36162 rows and 74 columns.

1832  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.15 seconds
      cpu time            0.11 seconds
      

1833  proc sort data= supplier_year_xvar_controls_2 out= supplier_year_xvar_controls_2 nodupkey; by
1833!  sgvkey year; run;

NOTE: There were 36162 observations read from the data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_2.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_2 has 36162 observations and 74 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.11 seconds
      cpu time            0.11 seconds
      

1834  
1835  
1836  /*Get all the M&As announced in t+3*/
1837  proc sql;
1838    create table supplier_year_xvar_controls_3 as
1839      select a.*, b.cusip6, b.permno,
1840      b.dateann as dateann_1, b.counterparty_gvkey, b.wanted, b.unwanted, b.wanted_rgvkey,
1840! b.wanted_rsgvkey
1841      from supplier_year_xvar_controls_2 a
1842      left join temp.mna_wlinks b on a.sgvkey =b.gvkey and a.datadate + 365*3 <= b.dateann  <=
1842! a.datadate + 365*4  /*t = 3*/
1843      order by a.sgvkey, a.year;
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_3 created, with 39815 rows and 82 columns.

1844  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.38 seconds
      cpu time            0.35 seconds
      

1845  
1846  
1847  data supplier_year_xvar_controls_4;
1848      set supplier_year_xvar_controls_3;
1849      array NumVar wanted unwanted wanted_rgvkey wanted_rsgvkey;
1850      do over NumVar;
1851      if NumVar=. then NumVar=0;
1852     end;
1853  run;

NOTE: There were 39815 observations read from the data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_3.
NOTE: The data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_4 has 39815 observations and 82 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1854  
1855  proc sql;
1856  create table supplier_year_xvar_controls_5 as select
1857      *, sum(wanted) as wanted3, sum(unwanted) as unwanted3,
1858      sum(wanted_rsgvkey) as wanted_rsgvkey3, sum(wanted_rgvkey) as wanted_rgvkey3
1859  from supplier_year_xvar_controls_4 group by sgvkey, datadate;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_5 created, with 39815 rows and 86 columns.

1860  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.24 seconds
      cpu time            0.29 seconds
      

1861  
1862  proc sort data= supplier_year_xvar_controls_5; by sgvkey datadate descending wanted; run;

NOTE: There were 39815 observations read from the data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_5.
NOTE: The data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_5 has 39815 observations and 86 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.12 seconds
      cpu time            0.12 seconds
      

1863  proc sort data= supplier_year_xvar_controls_5 nodupkey; by sgvkey datadate; run;

NOTE: There were 39815 observations read from the data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_5.
NOTE: 3653 observations with duplicate key values were deleted.
NOTE: The data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_5 has 36162 observations and 86 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.12 seconds
      cpu time            0.10 seconds
      

1864  
1865  
1866  /*Get all the M&As announced in t+1*/
1867  proc sql;
1868    create table mna_t_1 as
1869      select a.*, b.cusip6, b.permno,
1870      b.dateann as dateann_t_1, b.counterparty_gvkey, b.wanted, b.unwanted
1871      from supplier_year_xvar_controls_2 a
1872      left join temp.mna_wlinks b on a.sgvkey =b.gvkey and a.datadate + 365*1 <= b.dateann  <=
1872! a.datadate + 365*2  /*t = 3*/
1873      order by a.sgvkey, a.year;
NOTE: Table WORK.MNA_T_1 created, with 40539 rows and 80 columns.

1874  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.31 seconds
      cpu time            0.34 seconds
      

1875  
1876  
1877  data mna_t_1;
1878      set mna_t_1;
1879      array NumVar wanted unwanted;
1880      do over NumVar;
1881      if NumVar=. then NumVar=0;
1882     end;
1883  run;

NOTE: There were 40539 observations read from the data set WORK.MNA_T_1.
NOTE: The data set WORK.MNA_T_1 has 40539 observations and 80 variables.
NOTE: DATA statement used (Total process time):
      real time           0.10 seconds
      cpu time            0.10 seconds
      

1884  
1885  proc sql;
1886  create table mna_t_1 as select
1887      *, sum(wanted) as wanted3_1_sic3, sum(unwanted) as unwanted3_1_sic3
1888  from mna_t_1 group by sgvkey, datadate;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.MNA_T_1 created, with 40539 rows and 82 columns.

1889  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.25 seconds
      cpu time            0.25 seconds
      

1890  
1891  proc sort data= mna_t_1; by sgvkey datadate descending wanted; run;

NOTE: There were 40539 observations read from the data set WORK.MNA_T_1.
NOTE: The data set WORK.MNA_T_1 has 40539 observations and 82 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.11 seconds
      cpu time            0.12 seconds
      

1892  proc sort data= mna_t_1 nodupkey; by sgvkey datadate; run;

NOTE: There were 40539 observations read from the data set WORK.MNA_T_1.
NOTE: 4377 observations with duplicate key values were deleted.
NOTE: The data set WORK.MNA_T_1 has 36162 observations and 82 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.09 seconds
      

1893  
1894  
1895  proc sql;
1896    create table supplier_year_xvar_controls_6 as
1897      select a.*, b.wanted3_1_sic3,b.unwanted3_1_sic3
1898      from supplier_year_xvar_controls_5 a
1899      left join mna_t_1 b
1900      on a.sgvkey = b.sgvkey and a.srcdate = b.srcdate;
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_6 created, with 36162 rows and 88 columns.

1901  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.23 seconds
      cpu time            0.21 seconds
      

1902  
1903  
1904  /*Get all the M&As announced in t+2. There can be multiple per firm*/
1905  proc sql;
1906    create table mna_t_2 as
1907      select a.*, b.cusip6, b.permno,
1908      b.dateann as dateann_t_2, b.counterparty_gvkey, b.wanted, b.unwanted
1909      from supplier_year_xvar_controls_2 a
1910      left join temp.mna_wlinks b on a.sgvkey =b.gvkey and a.datadate + 365*2 <= b.dateann  <=
1910! a.datadate + 365*3
1911      order by a.sgvkey, a.year;
NOTE: Table WORK.MNA_T_2 created, with 40220 rows and 80 columns.

1912  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.24 seconds
      cpu time            0.25 seconds
      

1913  
1914  data mna_t_2;
1915      set mna_t_2;
1916      array NumVar wanted unwanted;
1917      do over NumVar;
1918      if NumVar=. then NumVar=0;
1919     end;
1920  run;

NOTE: There were 40220 observations read from the data set WORK.MNA_T_2.
NOTE: The data set WORK.MNA_T_2 has 40220 observations and 80 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

1921  
1922  proc sql;
1923  create table mna_t_2 as select
1924      *, sum(wanted) as wanted3_2_sic3, sum(unwanted) as unwanted3_2_sic3
1925  from mna_t_2 group by sgvkey, datadate;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.MNA_T_2 created, with 40220 rows and 82 columns.

1926  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.23 seconds
      cpu time            0.28 seconds
      

1927  
1928  proc sort data= mna_t_2; by sgvkey datadate descending wanted; run;

NOTE: There were 40220 observations read from the data set WORK.MNA_T_2.
NOTE: The data set WORK.MNA_T_2 has 40220 observations and 82 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.11 seconds
      cpu time            0.12 seconds
      

1929  proc sort data= mna_t_2 nodupkey; by sgvkey datadate; run;

NOTE: There were 40220 observations read from the data set WORK.MNA_T_2.
NOTE: 4058 observations with duplicate key values were deleted.
NOTE: The data set WORK.MNA_T_2 has 36162 observations and 82 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.09 seconds
      cpu time            0.09 seconds
      

1930  
1931  proc sql;
1932    create table supplier_year_xvar_controls_7 as
1933      select a.*, b.wanted3_2_sic3,b.unwanted3_2_sic3
1934      from supplier_year_xvar_controls_6 a
1935      left join mna_t_2 b
1936      on a.sgvkey = b.sgvkey and a.srcdate = b.srcdate;
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_7 created, with 36162 rows and 90 columns.

1937  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.13 seconds
      cpu time            0.12 seconds
      

1938  
1939  proc sort data= temp.mna_wlinks out = restruct nodupkey; by sic3 year; run;

NOTE: There were 73890 observations read from the data set TEMP.MNA_WLINKS.
NOTE: 66926 observations with duplicate key values were deleted.
NOTE: The data set WORK.RESTRUCT has 6964 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.15 seconds
      cpu time            0.15 seconds
      

1940  
1941  data restruct; set restruct;
1942  where restruct ^=.; run;

NOTE: There were 6945 observations read from the data set WORK.RESTRUCT.
      WHERE restruct not = .;
NOTE: The data set WORK.RESTRUCT has 6945 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

1943  
1944  proc sql;
1945    create table supplier_year_xvar_controls_8 as
1946      select a.*, b.restruct
1947      from supplier_year_xvar_controls_7 a
1948      left join restruct b
1949      on a.sic3 = b.sic3 and a.year = b.year;
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_8 created, with 36162 rows and 91 columns.

1950  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.15 seconds
      cpu time            0.18 seconds
      

1951  
1952  proc sort data = supplier_year_xvar_controls_8 nodupkey; by sgvkey srcdate; run;

NOTE: There were 36162 observations read from the data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_8.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_8 has 36162 observations and 91 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.08 seconds
      cpu time            0.09 seconds
      

1953  
1954  *For DID add Customer Treat and post;
1955  proc sql;
1956    create table supplier_year_xvar_controls_10 as
1957      select a.*, b.cust_treat2,b.Announcement_date
1958      from supplier_year_xvar_controls_8 a
1959      left join temp.CO_shock_20221220 b
1960      on a.sgvkey = b.sgvkey and a.srcdate -365*3 <= b.Announcement_date <= a.srcdate +365*3;
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_10 created, with 39630 rows and 93 columns.

1961  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.08 seconds
      cpu time            0.07 seconds
      

1962  
1963  
1964  data supplier_year_xvar_controls_11; set supplier_year_xvar_controls_10;
1965      if Announcement_date -365*3 <=srcdate <Announcement_date then post =0;
1966      if Announcement_date <srcdate <=Announcement_date+365*3 then post =1;
1967      if Announcement_date -365*3 <=srcdate <Announcement_date then pre =1;
1968      if Announcement_date <srcdate <=Announcement_date+365*3 then pre =0;
1969  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      28742 at 1965:26   28742 at 1966:54   28742 at 1967:26   28742 at 1968:54
NOTE: There were 39630 observations read from the data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_10.
NOTE: The data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_11 has 39630 observations and 95 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds
      

1970  
1971  proc sort data = supplier_year_xvar_controls_11 out = supplier_year_xvar_controls_11; by
1971! sgvkey year descending cust_treat2; run;

NOTE: There were 39630 observations read from the data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_11.
NOTE: The data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_11 has 39630 observations and 95 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.14 seconds
      cpu time            0.12 seconds
      

1972  proc sort data = supplier_year_xvar_controls_11 out = supplier_year_xvar_controls_12 nodupkey
1972! ; by sgvkey year; run;

NOTE: There were 39630 observations read from the data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_11.
NOTE: 3468 observations with duplicate key values were deleted.
NOTE: The data set WORK.SUPPLIER_YEAR_XVAR_CONTROLS_12 has 36162 observations and 95 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.12 seconds
      cpu time            0.10 seconds
      

1973  
1974  proc sql;
1975          create table supplier_year_xvar_controls_13 as
1976          select *,
1977          sum(post) as post_n, sum(pre) as pre_n
1978          from supplier_year_xvar_controls_12
1979          group by sgvkey, announcement_date;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.SUPPLIER_YEAR_XVAR_CONTROLS_13 created, with 36162 rows and 97 columns.

1980  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.21 seconds
      cpu time            0.18 seconds
      

1981  
1982  
1983  proc export data=work.supplier_year_xvar_controls_13
1984  
1985      outfile="..\..\Data\JAR\temp\sample20221217.dta"
1986      DBMS= dta REPLACE;
1987  run;

NOTE: The export data set has 36162 observations and 97 variables.
NOTE: "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\temp\sample20221217.dta" file was 
      successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           0.16 seconds
      cpu time            0.15 seconds
  
----------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR\log_3_1.smcl
  log type:  smcl
 opened on:  24 Jul 2024, 21:50:25

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. 
. ********************************************************************************
> ****************************************************
. **Cross sectional rsi_patent
. ********************************************************************************
> ****************************************************
. 
. *****************NAICS crosswalks************
. 
. glo path = "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\DataConstruction\
> Ziqing\MnA experiment\data"

. glo path2 = "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR"

. glo path3 = "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets"

. 
. ****tech class to naics
. import delimited "$path/ALP_CPC/NAICS_1997/cpc4_to_naics97_4.txt", varnames(1) c
> lear 
(encoding automatically selected: ISO-8859-1)
(3 vars, 3,117 obs)

. rename naics97_4 naicsid

. *max ,but equal when tie
. gen probability_weight_m = 0

. bys cpc4 : egen weight2 = max(probability_weight)

. replace probability_weight_m = 1 if probability_weight == weight2
(655 real changes made)

. bys cpc4 : egen temp = sum(probability_weight_m)

. replace probability_weight_m = 1/temp if temp>1
(0 real changes made)

. *average
. bys cpc4 : egen weight3 = count(naicsid)

. gen probability_weight_a = 0

. replace probability_weight_a = 1/weight3
(3,117 real changes made)

. keep cpc4 naicsid probability_weight*

. save "$path2/temp/cpc_to_naics_97_4.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/cpc_to_naics_97_4.dta saved

. 
. import delimited "$path/ALP_CPC/NAICS_2002/cpc4_to_naics02_4.txt", varnames(1) c
> lear 
(encoding automatically selected: ISO-8859-1)
(3 vars, 3,199 obs)

. rename naics02_4 naicsid

. *max ,but equal when tie
. gen probability_weight_m = 0

. bys cpc4 : egen weight2 = max(probability_weight)

. replace probability_weight_m = 1 if probability_weight == weight2
(655 real changes made)

. bys cpc4 : egen temp = sum(probability_weight_m)

. replace probability_weight_m = 1/temp if temp>1
(0 real changes made)

. *average
. bys cpc4 : egen weight3 = count(naicsid)

. gen probability_weight_a = 0

. replace probability_weight_a = 1/weight3
(3,199 real changes made)

. keep cpc4 naicsid probability_weight*

. save "$path2/temp/cpc_to_naics_02_4.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/cpc_to_naics_02_4.dta saved

. 
. import delimited "$path/ALP_CPC/NAICS_2007/cpc4_to_naics07_4.txt", varnames(1) c
> lear 
(encoding automatically selected: ISO-8859-1)
(3 vars, 3,190 obs)

. rename naics07_4 naicsid

. *max ,but equal when tie
. gen probability_weight_m = 0

. bys cpc4 : egen weight2 = max(probability_weight)

. replace probability_weight_m = 1 if probability_weight == weight2
(655 real changes made)

. bys cpc4 : egen temp = sum(probability_weight_m)

. replace probability_weight_m = 1/temp if temp>1
(0 real changes made)

. *average
. bys cpc4 : egen weight3 = count(naicsid)

. gen probability_weight_a = 0

. replace probability_weight_a = 1/weight3
(3,190 real changes made)

. keep cpc4 naicsid probability_weight*

. save "$path2/temp/cpc_to_naics_07_4.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/cpc_to_naics_07_4.dta saved

. 
. 
. *before 2002
. use "$path2/temp/grant_public.dta",clear

. keep if year<2002
(208,717 observations deleted)

. rename cpc_group_id cpc4

. joinby cpc4 using "$path2/temp/cpc_to_naics_97_4.dta"

. rename cpc4 cpc_group_id

. *calculate number of granted in permno-naics-year level
. bys permno naicsid year: gen num_granted_w = sum(num_granted * probability_weigh
> t)

. bys permno naicsid year: gen num_granted_a = sum(num_granted * probability_weigh
> t_a)

. bys permno naicsid year: gen num_granted_m = sum(num_granted * probability_weigh
> t_m)

. keep permno naicsid year num_granted*

. drop num_granted

. duplicates drop permno naicsid year,force

Duplicates in terms of permno naicsid year

(676,391 observations deleted)

. save "$path2/temp/grant_public_naics_before02.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/grant_public_naics_before02.dta saved

. 
. *2002-2007
. use "$path2/temp/grant_public.dta",clear

. keep if year>=2002 & year<2007
(385,915 observations deleted)

. rename cpc_group_id cpc4

. joinby cpc4 using "$path2/temp/cpc_to_naics_02_4.dta"

. rename cpc4 cpc_group_id

. *calculate number of granted in permno-naics-year level
. bys permno naicsid year: gen num_granted_w = sum(num_granted * probability_weigh
> t)

. bys permno naicsid year: gen num_granted_a = sum(num_granted * probability_weigh
> t_a)

. bys permno naicsid year: gen num_granted_m = sum(num_granted * probability_weigh
> t_m)

. keep permno naicsid year num_granted*

. drop num_granted

. duplicates drop permno naicsid year,force

Duplicates in terms of permno naicsid year

(182,403 observations deleted)

. save "$path2/temp/grant_public_naics_02_07.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/grant_public_naics_02_07.dta saved

. 
. *after 2007
. use "$path2/temp/grant_public.dta",clear

. keep if year>=2007
(297,408 observations deleted)

. rename cpc_group_id cpc4

. joinby cpc4 using "$path2/temp/cpc_to_naics_07_4.dta"

. rename cpc4 cpc_group_id

. *calculate number of granted in permno-naics-year level
. bys permno naicsid year: gen num_granted_w = sum(num_granted * probability_weigh
> t)

. bys permno naicsid year: gen num_granted_a = sum(num_granted * probability_weigh
> t_a)

. bys permno naicsid year: gen num_granted_m = sum(num_granted * probability_weigh
> t_m)

. keep permno naicsid year num_granted*

. drop num_granted

. duplicates drop permno naicsid year,force

Duplicates in terms of permno naicsid year

(475,107 observations deleted)

. save "$path2/temp/grant_public_naics_after07.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/grant_public_naics_after07.dta saved

. 
. 
. 
. *append the data together, generate the permno-naics-year level data
. use "$path2/temp/grant_public_naics_before02.dta",clear

. append using "$path2/temp/grant_public_naics_02_07.dta"

. append using "$path2/temp/grant_public_naics_after07.dta"

. unique naicsid
Number of unique values of naicsid is  286
Number of records is  1148734

. 
. egen naicsid_num = group(naicsid)

. drop naicsid

. reshape wide num_granted_w num_granted_a num_granted_m, i(permno year) j(naicsid
> _num)
(j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
>  30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 5
> 6 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 
> 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 1
> 07 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 1
> 27 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 1
> 47 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 1
> 67 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 1
> 87 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 2
> 07 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 2
> 27 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 2
> 47 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 2
> 67 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286)

Data                               Long   ->   Wide
-----------------------------------------------------------------------------
Number of observations        1,148,734   ->   60,221      
Number of variables                   6   ->   860         
j variable (286 values)     naicsid_num   ->   (dropped)
xij variables:
                          num_granted_w   ->   num_granted_w1 num_granted_w2 ... n
> um_granted_w286
                          num_granted_a   ->   num_granted_a1 num_granted_a2 ... n
> um_granted_a286
                          num_granted_m   ->   num_granted_m1 num_granted_m2 ... n
> um_granted_m286
-----------------------------------------------------------------------------

. save "$path2/temp/grant_public_reshaped_naics.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/grant_public_reshaped_naics.dta saved

. 
. 
. use "$path2/compa78_20_20220410.dta",clear
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/compa78_20_20220410.dta not found
r(601);

end of do-file

r(601);

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. 
. use "$path3/compa78_20_20220410.dta",clear

. destring gvkey, gen(gvkey_num)
gvkey: all characters numeric; gvkey_num generated as long

. drop if at == .
(63,905 observations deleted)

. *keep key variable
. keep gvkey_num datadate fyear

. 
. save "$path2/temp/compa_temp1.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/compa_temp1.dta
    saved

. 
. 
. *get cpc_group_id of each patent (raw data from patents view)
. use "$path/PatentsView_KPSS_combo_yr_figs.dta", clear

. replace cpc_group_id=subinstr(cpc_group_id,"b","",.)
(6,779,677 real changes made)

. replace cpc_group_id=subinstr(cpc_group_id,"'","",.)
(6,779,677 real changes made)

. keep if cpc_group_id !="nan"
(749,286 observations deleted)

. keep patent_id cpc_group_id

. duplicates drop

Duplicates in terms of all variables

(0 observations are duplicates)

. destring patent_id, replace force
patent_id: all characters numeric; replaced as long

. save "$path2/temp/link.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/link.dta saved

. 
. *get the grant_date of each patent (raw data from patentsview)
. use "$path/patent.dta",clear

. rename id patent_id

. rename date grant_date

. keep patent_id grant_date

. duplicates drop patent_id,force

Duplicates in terms of patent_id

(0 observations are duplicates)

. gen date2 = date(grant_date, "YMD")

. format date2 %td

. drop grant_date

. rename date2 grant_date

. destring patent_id, replace force
patent_id: contains nonnumeric characters; replaced as long
(748887 missing values generated)

. duplicates drop patent_id,force

Duplicates in terms of patent_id

(748,886 observations deleted)

. merge 1:1 patent_id using "$path2/temp/link.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                       462,495
        from master                   462,495  (_merge==1)
        from using                          0  (_merge==2)

    Matched                         6,779,677  (_merge==3)
    -----------------------------------------

. keep if _m == 3
(462,495 observations deleted)

. drop _m

. save "$path2/temp/patent_grant_date1.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/patent_grant_date1.dta saved

. 
. 
. *---Merge with the patents granted by Public firms (raw data from Kogan EtAl)
. *generate a firm-tech class-year level data
. import delimited "$path/KPSS_2020_public.csv", clear 
(encoding automatically selected: ISO-8859-1)
(7 vars, 3,053,011 obs)

. rename patent_num patent_id

. merge 1:1 patent_id using "$path2/temp/patent_grant_date1.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                     5,054,758
        from master                   664,046  (_merge==1)
        from using                  4,390,712  (_merge==2)

    Matched                         2,388,965  (_merge==3)
    -----------------------------------------

. 
. keep if _m == 3
(5,054,758 observations deleted)

. drop _m

. gen year = year(grant_date)

. 
. duplicates drop patent_id, force

Duplicates in terms of patent_id

(0 observations are duplicates)

. gen flag = 1

. 
. collapse (sum) num_granted = flag, by(cpc_group_id year permno)

. 
. save "$path2/temp/grant_public.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/grant_public.dta saved

.         
. 
. *generate the cpc_group_id link
. use "$path2/temp/grant_public.dta",clear

. egen cpc_num = group(cpc_group_id)

. keep cpc* 

. duplicates drop

Duplicates in terms of all variables

(445,389 observations deleted)

. save "$path2/temp/cpc_link.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/cpc_link.dta
    saved

. *631 unique cpc groups
. 
. *reshape the data 
. use "$path2/temp/grant_public.dta",clear

. egen cpc_num = group(cpc_group_id)

. drop cpc_group_id

. reshape wide num_granted, i(permno year) j(cpc_num)
(j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
>  30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 5
> 6 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 
> 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 1
> 07 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 1
> 27 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 1
> 47 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 1
> 67 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 1
> 87 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 2
> 07 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 2
> 27 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 2
> 47 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 2
> 67 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 2
> 87 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 3
> 07 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 3
> 27 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 3
> 47 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 3
> 67 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 3
> 87 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 4
> 07 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 4
> 27 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 4
> 47 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 4
> 67 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 4
> 87 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 5
> 07 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 5
> 27 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 5
> 47 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 5
> 67 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 5
> 87 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 6
> 07 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 6
> 27 628 629 630 631)

Data                               Long   ->   Wide
-----------------------------------------------------------------------------
Number of observations          446,020   ->   60,257      
Number of variables                   4   ->   633         
j variable (631 values)         cpc_num   ->   (dropped)
xij variables:
                            num_granted   ->   num_granted1 num_granted2 ... num_g
> ranted631
-----------------------------------------------------------------------------

. save "$path2/temp/grant_public_reshaped.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/grant_public_reshaped.dta saved

. 
. *from CTMP7, get the spermno-cpermno-year data
. *This data is from 1976
. 
. use "$path3/Ctmp7_20221121.dta",clear

. keep spermno cpermno year

. drop if spermno == . & cpermno == .
(2,759 observations deleted)

. duplicates drop

Duplicates in terms of all variables

(8,907 observations deleted)

. save "$path2/temp/spermno_cpermno_pair.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/spermno_cpermno_pair.dta saved

. *66083 pairs
. 
. use "$path3/Ctmp7_20221121.dta",clear

. keep spermno cpermno sgvkey cgvkey srcdate year r_p_salecs_3_1 p_salecs

. duplicates drop

Duplicates in terms of all variables

(0 observations are duplicates)

. save "$path2/temp/sgvkey_cgvkey_pair.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/sgvkey_cgvkey_pair.dta saved

. *77749 pairs
. 
. *merge the dataset
. ***********************************
. *CPC tech class Group
. ***********************************
. use "$path2/temp/spermno_cpermno_pair.dta",clear

. *merge in the supplier patents
. rename spermno permno

. merge m:1 permno year using "$path2/temp/grant_public_reshaped.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                        95,807
        from master                    47,437  (_merge==1)
        from using                     48,370  (_merge==2)

    Matched                            18,646  (_merge==3)
    -----------------------------------------

. /
/ is not a valid command name
r(199);

end of do-file

r(199);

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. 
. drop if _m == 2
(48,370 observations deleted)

. drop _m

. rename permno spermno

. 
. forvalues i=1(1)631{
  2.         rename num_granted`i' s_num_granted`i'
  3. }

. 
. *merge in the supplier patents
. rename cpermno permno

. merge m:1 permno year using "$path2/temp/grant_public_reshaped.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                        78,728
        from master                    28,467  (_merge==1)
        from using                     50,261  (_merge==2)

    Matched                            37,616  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(50,261 observations deleted)

. drop _m

. rename permno cpermno

. 
. forvalues i=1(1)631{
  2.         rename num_granted`i' c_num_granted`i'
  3. }

. save "$path2/temp/supplier_customer_patent.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/supplier_customer_patent.dta saved

. 
. 
. ***********************************
. *Naics code
. ***********************************
. use "$path2/temp/spermno_cpermno_pair.dta",clear

. *merge in the supplier patents
. rename spermno permno

. *from code "cpc_naics.do"
. merge m:1 permno year using "$path2/temp/grant_public_reshaped_naics.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                        95,775
        from master                    47,439  (_merge==1)
        from using                     48,336  (_merge==2)

    Matched                            18,644  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(48,336 observations deleted)

. drop _m

. rename permno spermno

. 
. forvalues i=1(1)286{
  2.         rename num_granted_m`i' s_num_granted_m`i'
  3. }

. 
. *merge in the supplier patents
. rename cpermno permno

. merge m:1 permno year using "$path2/temp/grant_public_reshaped_naics.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                        78,694
        from master                    28,468  (_merge==1)
        from using                     50,226  (_merge==2)

    Matched                            37,615  (_merge==3)
    -----------------------------------------

. /
/ is not a valid command name
r(199);

end of do-file

r(199);

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. drop if _m == 2
(50,226 observations deleted)

. drop _m

. rename permno cpermno

. 
. forvalues i=1(1)286{
  2.         rename num_granted_m`i' c_num_granted_m`i'
  3. }

. save "$path2/temp/supplier_customer_patent_naics.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/supplier_customer_patent_naics.dta saved

. 
. 
end of do-file

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. *Merge into the sgvkey-cgvkey-year level data 
. use "$path2/temp/sgvkey_cgvkey_pair.dta",clear

. *merge in cpc_group level
. merge m:1 spermno cpermno year using "$path2/temp/supplier_customer_patent.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                         2,759
        from master                     2,759  (_merge==1)
        from using                          0  (_merge==2)

    Matched                            74,990  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(0 observations deleted)

. drop _m

. 
. 
. *generate the RSI variables
. *1. dummy variable equals 1 if both supplier and customer have at least one pate
> nt in the same tech class
. gen same_cpc_flag = 0

. 
. forvalues i=1(1)631{
  2.         replace same_cpc_flag = 1 if s_num_granted`i' >0 & s_num_granted`i'!=
> . & c_num_granted`i' >0 & c_num_granted`i'!=.
  3. }
(1 real change made)
(0 real changes made)
(17 real changes made)
(1 real change made)
(1 real change made)
(2 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(1 real change made)
(14 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(8 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(19 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(5 real changes made)
(19 real changes made)
(0 real changes made)
(11 real changes made)
(0 real changes made)
(0 real changes made)
(15 real changes made)
(1 real change made)
(1 real change made)
(252 real changes made)
(0 real changes made)
(0 real changes made)
(36 real changes made)
(2 real changes made)
(0 real changes made)
(14 real changes made)
(878 real changes made)
(28 real changes made)
(79 real changes made)
(5 real changes made)
(1 real change made)
(0 real changes made)
(5 real changes made)
(3 real changes made)
(1 real change made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(45 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(264 real changes made)
(9 real changes made)
(71 real changes made)
(18 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(32 real changes made)
(9 real changes made)
(17 real changes made)
(2 real changes made)
(0 real changes made)
(2 real changes made)
(24 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(2 real changes made)
(111 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(2 real changes made)
(0 real changes made)
(32 real changes made)
(38 real changes made)
(21 real changes made)
(16 real changes made)
(2 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(212 real changes made)
(42 real changes made)
(20 real changes made)
(65 real changes made)
(1 real change made)
(0 real changes made)
(27 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(23 real changes made)
(0 real changes made)
(3 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(238 real changes made)
(9 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(83 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(43 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(13 real changes made)
(28 real changes made)
(0 real changes made)
(0 real changes made)
(62 real changes made)
(44 real changes made)
(67 real changes made)
(81 real changes made)
(2 real changes made)
(0 real changes made)
(85 real changes made)
(2 real changes made)
(31 real changes made)
(109 real changes made)
(8 real changes made)
(22 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(34 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(25 real changes made)
(15 real changes made)
(1 real change made)
(4 real changes made)
(6 real changes made)
(0 real changes made)
(83 real changes made)
(0 real changes made)
(17 real changes made)
(23 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(12 real changes made)
(0 real changes made)
(0 real changes made)
(8 real changes made)
(7 real changes made)
(0 real changes made)
(60 real changes made)
(14 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(4 real changes made)
(2 real changes made)
(20 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(56 real changes made)
(194 real changes made)
(9 real changes made)
(0 real changes made)
(21 real changes made)
(0 real changes made)
(262 real changes made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(10 real changes made)
(0 real changes made)
(8 real changes made)
(3 real changes made)
(1 real change made)
(2 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(88 real changes made)
(1 real change made)
(25 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(4 real changes made)
(11 real changes made)
(1 real change made)
(88 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(1 real change made)
(9 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(31 real changes made)
(2 real changes made)
(6 real changes made)
(2 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(76 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(9 real changes made)
(5 real changes made)
(41 real changes made)
(3 real changes made)
(19 real changes made)
(12 real changes made)
(21 real changes made)
(4 real changes made)
(0 real changes made)
(14 real changes made)
(37 real changes made)
(2 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(7 real changes made)
(6 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(39 real changes made)
(32 real changes made)
(32 real changes made)
(33 real changes made)
(0 real changes made)
(22 real changes made)
(4 real changes made)
(28 real changes made)
(21 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(7 real changes made)
(11 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(2 real changes made)
(0 real changes made)
(61 real changes made)
(32 real changes made)
(19 real changes made)
(13 real changes made)
(1 real change made)
(1 real change made)
(13 real changes made)
(9 real changes made)
(4 real changes made)
(28 real changes made)
(160 real changes made)
(5 real changes made)
(0 real changes made)
(367 real changes made)
(46 real changes made)
(1 real change made)
(8 real changes made)
(0 real changes made)
(205 real changes made)
(0 real changes made)
(18 real changes made)
(17 real changes made)
(0 real changes made)
(0 real changes made)
(41 real changes made)
(12 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(17 real changes made)
(13 real changes made)
(25 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(958 real changes made)
(3 real changes made)
(0 real changes made)
(52 real changes made)
(0 real changes made)
(2 real changes made)
(122 real changes made)
(31 real changes made)
(2 real changes made)
(2 real changes made)
(0 real changes made)
(14 real changes made)
(0 real changes made)
(10 real changes made)
(0 real changes made)
(1 real change made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(8 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(29 real changes made)
(179 real changes made)
(48 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(3 real changes made)
(8 real changes made)
(33 real changes made)
(10 real changes made)
(33 real changes made)
(41 real changes made)
(0 real changes made)
(290 real changes made)
(10 real changes made)
(60 real changes made)
(26 real changes made)
(64 real changes made)
(12 real changes made)
(4 real changes made)
(0 real changes made)
(8 real changes made)
(5 real changes made)
(12 real changes made)
(3 real changes made)
(17 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(4 real changes made)
(31 real changes made)
(7 real changes made)
(10 real changes made)
(0 real changes made)
(23 real changes made)
(9 real changes made)
(20 real changes made)
(98 real changes made)
(7 real changes made)
(44 real changes made)
(0 real changes made)
(290 real changes made)
(100 real changes made)
(66 real changes made)
(29 real changes made)
(8 real changes made)
(0 real changes made)
(26 real changes made)
(8 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(1 real change made)
(65 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

. 
. 
. *2. number of tech class that supplier and customer both granted patents
. gen same_num_cpc = 0

. 
. forvalues i=1(1)631{
  2.         replace same_num_cpc = same_num_cpc + 1 if s_num_granted`i' >0 & s_nu
> m_granted`i'!=. & c_num_granted`i' >0 & c_num_granted`i'!=.
  3. }
(1 real change made)
(0 real changes made)
(17 real changes made)
(1 real change made)
(2 real changes made)
(2 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(1 real change made)
(14 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(19 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(5 real changes made)
(19 real changes made)
(0 real changes made)
(11 real changes made)
(1 real change made)
(0 real changes made)
(16 real changes made)
(1 real change made)
(1 real change made)
(253 real changes made)
(0 real changes made)
(0 real changes made)
(70 real changes made)
(3 real changes made)
(0 real changes made)
(15 real changes made)
(913 real changes made)
(73 real changes made)
(165 real changes made)
(15 real changes made)
(1 real change made)
(3 real changes made)
(5 real changes made)
(3 real changes made)
(1 real change made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(57 real changes made)
(0 real changes made)
(8 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(290 real changes made)
(17 real changes made)
(128 real changes made)
(48 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(56 real changes made)
(15 real changes made)
(28 real changes made)
(4 real changes made)
(1 real change made)
(2 real changes made)
(36 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(2 real changes made)
(150 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(10 real changes made)
(3 real changes made)
(0 real changes made)
(49 real changes made)
(63 real changes made)
(34 real changes made)
(31 real changes made)
(4 real changes made)
(5 real changes made)
(2 real changes made)
(0 real changes made)
(4 real changes made)
(381 real changes made)
(112 real changes made)
(38 real changes made)
(118 real changes made)
(5 real changes made)
(1 real change made)
(56 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(43 real changes made)
(0 real changes made)
(5 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(432 real changes made)
(44 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(298 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(90 real changes made)
(0 real changes made)
(1 real change made)
(23 real changes made)
(0 real changes made)
(1 real change made)
(9 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(41 real changes made)
(86 real changes made)
(1 real change made)
(0 real changes made)
(174 real changes made)
(120 real changes made)
(235 real changes made)
(292 real changes made)
(30 real changes made)
(0 real changes made)
(252 real changes made)
(9 real changes made)
(178 real changes made)
(523 real changes made)
(40 real changes made)
(174 real changes made)
(0 real changes made)
(79 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(1 real change made)
(0 real changes made)
(339 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(106 real changes made)
(101 real changes made)
(6 real changes made)
(39 real changes made)
(11 real changes made)
(0 real changes made)
(146 real changes made)
(0 real changes made)
(52 real changes made)
(64 real changes made)
(3 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(13 real changes made)
(0 real changes made)
(0 real changes made)
(33 real changes made)
(40 real changes made)
(0 real changes made)
(178 real changes made)
(59 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(10 real changes made)
(9 real changes made)
(22 real changes made)
(50 real changes made)
(124 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(177 real changes made)
(582 real changes made)
(48 real changes made)
(0 real changes made)
(91 real changes made)
(1 real change made)
(666 real changes made)
(2 real changes made)
(0 real changes made)
(71 real changes made)
(119 real changes made)
(0 real changes made)
(56 real changes made)
(30 real changes made)
(27 real changes made)
(14 real changes made)
(3 real changes made)
(66 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(14 real changes made)
(48 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(17 real changes made)
(2 real changes made)
(0 real changes made)
(16 real changes made)
(20 real changes made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(388 real changes made)
(33 real changes made)
(131 real changes made)
(3 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(33 real changes made)
(9 real changes made)
(61 real changes made)
(6 real changes made)
(336 real changes made)
(0 real changes made)
(23 real changes made)
(1 real change made)
(6 real changes made)
(0 real changes made)
(76 real changes made)
(2 real changes made)
(66 real changes made)
(7 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(2 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(12 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(6 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(122 real changes made)
(8 real changes made)
(29 real changes made)
(50 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(87 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(3 real changes made)
(40 real changes made)
(0 real changes made)
(146 real changes made)
(45 real changes made)
(167 real changes made)
(56 real changes made)
(138 real changes made)
(72 real changes made)
(181 real changes made)
(49 real changes made)
(0 real changes made)
(97 real changes made)
(255 real changes made)
(27 real changes made)
(57 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(3 real changes made)
(3 real changes made)
(69 real changes made)
(110 real changes made)
(97 real changes made)
(1 real change made)
(62 real changes made)
(0 real changes made)
(0 real changes made)
(232 real changes made)
(289 real changes made)
(315 real changes made)
(278 real changes made)
(7 real changes made)
(325 real changes made)
(133 real changes made)
(236 real changes made)
(179 real changes made)
(15 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(12 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(13 real changes made)
(24 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(4 real changes made)
(1 real change made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(10 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(66 real changes made)
(0 real changes made)
(8 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(35 real changes made)
(78 real changes made)
(0 real changes made)
(7 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(9 real changes made)
(3 real changes made)
(0 real changes made)
(41 real changes made)
(4 real changes made)
(1 real change made)
(296 real changes made)
(178 real changes made)
(126 real changes made)
(113 real changes made)
(5 real changes made)
(7 real changes made)
(112 real changes made)
(70 real changes made)
(147 real changes made)
(187 real changes made)
(900 real changes made)
(110 real changes made)
(10 real changes made)
(793 real changes made)
(271 real changes made)
(11 real changes made)
(30 real changes made)
(0 real changes made)
(702 real changes made)
(0 real changes made)
(183 real changes made)
(78 real changes made)
(1 real change made)
(0 real changes made)
(285 real changes made)
(51 real changes made)
(10 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(286 real changes made)
(161 real changes made)
(117 real changes made)
(34 real changes made)
(0 real changes made)
(5 real changes made)
(1,777 real changes made)
(9 real changes made)
(1 real change made)
(339 real changes made)
(0 real changes made)
(57 real changes made)
(402 real changes made)
(305 real changes made)
(2 real changes made)
(55 real changes made)
(1 real change made)
(62 real changes made)
(0 real changes made)
(77 real changes made)
(27 real changes made)
(46 real changes made)
(19 real changes made)
(0 real changes made)
(0 real changes made)
(27 real changes made)
(183 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(10 real changes made)
(42 real changes made)
(188 real changes made)
(567 real changes made)
(456 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(14 real changes made)
(31 real changes made)
(35 real changes made)
(190 real changes made)
(62 real changes made)
(241 real changes made)
(269 real changes made)
(0 real changes made)
(1,318 real changes made)
(204 real changes made)
(193 real changes made)
(299 real changes made)
(585 real changes made)
(181 real changes made)
(24 real changes made)
(3 real changes made)
(62 real changes made)
(76 real changes made)
(230 real changes made)
(206 real changes made)
(296 real changes made)
(10 real changes made)
(125 real changes made)
(1 real change made)
(58 real changes made)
(24 real changes made)
(59 real changes made)
(295 real changes made)
(157 real changes made)
(222 real changes made)
(37 real changes made)
(463 real changes made)
(214 real changes made)
(407 real changes made)
(681 real changes made)
(82 real changes made)
(363 real changes made)
(4 real changes made)
(1,491 real changes made)
(545 real changes made)
(632 real changes made)
(360 real changes made)
(109 real changes made)
(25 real changes made)
(460 real changes made)
(174 real changes made)
(0 real changes made)
(3 real changes made)
(22 real changes made)
(23 real changes made)
(779 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

. 
. *3. number of patents that customers granted in the same industry as the supplie
> r
. gen same_cpc_patents = 0

. forvalues i=1(1)631{
  2.         replace same_cpc_patents = same_num_cpc + c_num_granted`i' if s_num_g
> ranted`i' >0 & s_num_granted`i'!=. & c_num_granted`i' >0 & c_num_granted`i'!=.
  3. }
(1 real change made)
(0 real changes made)
(17 real changes made)
(1 real change made)
(2 real changes made)
(2 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(1 real change made)
(14 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(19 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(5 real changes made)
(19 real changes made)
(0 real changes made)
(11 real changes made)
(1 real change made)
(0 real changes made)
(16 real changes made)
(1 real change made)
(1 real change made)
(252 real changes made)
(0 real changes made)
(0 real changes made)
(69 real changes made)
(3 real changes made)
(0 real changes made)
(15 real changes made)
(911 real changes made)
(71 real changes made)
(162 real changes made)
(14 real changes made)
(1 real change made)
(3 real changes made)
(5 real changes made)
(3 real changes made)
(1 real change made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(53 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(288 real changes made)
(16 real changes made)
(116 real changes made)
(42 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(49 real changes made)
(14 real changes made)
(24 real changes made)
(3 real changes made)
(0 real changes made)
(2 real changes made)
(33 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(2 real changes made)
(145 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(3 real changes made)
(0 real changes made)
(43 real changes made)
(50 real changes made)
(28 real changes made)
(25 real changes made)
(4 real changes made)
(4 real changes made)
(2 real changes made)
(0 real changes made)
(3 real changes made)
(335 real changes made)
(96 real changes made)
(34 real changes made)
(102 real changes made)
(2 real changes made)
(1 real change made)
(50 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(43 real changes made)
(0 real changes made)
(4 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(399 real changes made)
(39 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(253 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(7 real changes made)
(0 real changes made)
(88 real changes made)
(0 real changes made)
(1 real change made)
(23 real changes made)
(0 real changes made)
(1 real change made)
(9 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(31 real changes made)
(65 real changes made)
(0 real changes made)
(0 real changes made)
(161 real changes made)
(111 real changes made)
(206 real changes made)
(276 real changes made)
(28 real changes made)
(0 real changes made)
(244 real changes made)
(9 real changes made)
(154 real changes made)
(512 real changes made)
(39 real changes made)
(168 real changes made)
(0 real changes made)
(74 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(1 real change made)
(0 real changes made)
(327 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(104 real changes made)
(94 real changes made)
(6 real changes made)
(37 real changes made)
(9 real changes made)
(0 real changes made)
(135 real changes made)
(0 real changes made)
(42 real changes made)
(59 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(13 real changes made)
(0 real changes made)
(0 real changes made)
(30 real changes made)
(33 real changes made)
(0 real changes made)
(158 real changes made)
(51 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(8 real changes made)
(8 real changes made)
(16 real changes made)
(43 real changes made)
(105 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(169 real changes made)
(563 real changes made)
(46 real changes made)
(0 real changes made)
(84 real changes made)
(1 real change made)
(655 real changes made)
(2 real changes made)
(0 real changes made)
(58 real changes made)
(99 real changes made)
(0 real changes made)
(44 real changes made)
(23 real changes made)
(14 real changes made)
(8 real changes made)
(3 real changes made)
(61 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(11 real changes made)
(40 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(14 real changes made)
(2 real changes made)
(0 real changes made)
(15 real changes made)
(15 real changes made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(375 real changes made)
(30 real changes made)
(125 real changes made)
(3 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(23 real changes made)
(7 real changes made)
(46 real changes made)
(4 real changes made)
(290 real changes made)
(0 real changes made)
(16 real changes made)
(1 real change made)
(6 real changes made)
(0 real changes made)
(58 real changes made)
(1 real change made)
(53 real changes made)
(7 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(2 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(10 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(5 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(116 real changes made)
(6 real changes made)
(24 real changes made)
(43 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(86 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(34 real changes made)
(0 real changes made)
(133 real changes made)
(43 real changes made)
(157 real changes made)
(46 real changes made)
(122 real changes made)
(63 real changes made)
(170 real changes made)
(41 real changes made)
(0 real changes made)
(78 real changes made)
(233 real changes made)
(26 real changes made)
(51 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(3 real changes made)
(3 real changes made)
(53 real changes made)
(96 real changes made)
(79 real changes made)
(0 real changes made)
(43 real changes made)
(0 real changes made)
(0 real changes made)
(188 real changes made)
(253 real changes made)
(291 real changes made)
(252 real changes made)
(6 real changes made)
(309 real changes made)
(120 real changes made)
(195 real changes made)
(152 real changes made)
(8 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(8 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(10 real changes made)
(17 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(1 real change made)
(3 real changes made)
(1 real change made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(7 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(54 real changes made)
(0 real changes made)
(7 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(22 real changes made)
(53 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(2 real changes made)
(0 real changes made)
(32 real changes made)
(4 real changes made)
(1 real change made)
(234 real changes made)
(146 real changes made)
(96 real changes made)
(89 real changes made)
(4 real changes made)
(3 real changes made)
(83 real changes made)
(51 real changes made)
(106 real changes made)
(160 real changes made)
(809 real changes made)
(89 real changes made)
(9 real changes made)
(739 real changes made)
(241 real changes made)
(11 real changes made)
(24 real changes made)
(0 real changes made)
(645 real changes made)
(0 real changes made)
(174 real changes made)
(71 real changes made)
(1 real change made)
(0 real changes made)
(269 real changes made)
(48 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(241 real changes made)
(128 real changes made)
(108 real changes made)
(27 real changes made)
(0 real changes made)
(3 real changes made)
(1,726 real changes made)
(9 real changes made)
(1 real change made)
(329 real changes made)
(0 real changes made)
(55 real changes made)
(387 real changes made)
(296 real changes made)
(2 real changes made)
(50 real changes made)
(1 real change made)
(55 real changes made)
(0 real changes made)
(65 real changes made)
(24 real changes made)
(37 real changes made)
(13 real changes made)
(0 real changes made)
(0 real changes made)
(22 real changes made)
(169 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(32 real changes made)
(182 real changes made)
(559 real changes made)
(434 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(14 real changes made)
(22 real changes made)
(27 real changes made)
(163 real changes made)
(59 real changes made)
(190 real changes made)
(244 real changes made)
(0 real changes made)
(1,247 real changes made)
(191 real changes made)
(179 real changes made)
(268 real changes made)
(509 real changes made)
(159 real changes made)
(22 real changes made)
(2 real changes made)
(44 real changes made)
(66 real changes made)
(187 real changes made)
(173 real changes made)
(246 real changes made)
(7 real changes made)
(95 real changes made)
(1 real change made)
(50 real changes made)
(20 real changes made)
(46 real changes made)
(269 real changes made)
(139 real changes made)
(175 real changes made)
(23 real changes made)
(399 real changes made)
(187 real changes made)
(357 real changes made)
(633 real changes made)
(72 real changes made)
(329 real changes made)
(4 real changes made)
(1,439 real changes made)
(525 real changes made)
(607 real changes made)
(352 real changes made)
(94 real changes made)
(22 real changes made)
(438 real changes made)
(141 real changes made)
(0 real changes made)
(3 real changes made)
(21 real changes made)
(18 real changes made)
(714 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

. 
. drop s_num_granted* c_num_granted*

. save "$path2/temp/temp1.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/temp1.dta saved

. 
. use "$path2/temp/temp1.dta",clear

. *merge in naics level
. merge m:1 spermno cpermno year using "$path2/temp/supplier_customer_patent_naics
> .dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                         2,759
        from master                     2,759  (_merge==1)
        from using                          0  (_merge==2)

    Matched                            74,990  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(0 observations deleted)

. drop _m

. 
. 
. *generate the RSI variables
. *1. dummy variable equals 1 if both supplier and customer have at least one pate
> nt in the same naics
. gen same_naics_flag_m = 0

. 
. forvalues i=1(1)286{
  2.         replace same_naics_flag_m = 1 if s_num_granted_m`i' >0 & s_num_grante
> d_m`i'!=. & c_num_granted_m`i' >0 & c_num_granted_m`i'!=.
  3. }
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(1 real change made)
(21 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(9 real changes made)
(0 real changes made)
(19 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(59 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(6 real changes made)
(2 real changes made)
(1 real change made)
(0 real changes made)
(2 real changes made)
(395 real changes made)
(4 real changes made)
(9 real changes made)
(4 real changes made)
(5 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(79 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(8 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(32 real changes made)
(70 real changes made)
(1 real change made)
(3 real changes made)
(70 real changes made)
(0 real changes made)
(6 real changes made)
(11 real changes made)
(66 real changes made)
(15 real changes made)
(9 real changes made)
(181 real changes made)
(73 real changes made)
(63 real changes made)
(48 real changes made)
(45 real changes made)
(0 real changes made)
(58 real changes made)
(0 real changes made)
(8 real changes made)
(0 real changes made)
(351 real changes made)
(4 real changes made)
(18 real changes made)
(24 real changes made)
(123 real changes made)
(19 real changes made)
(0 real changes made)
(18 real changes made)
(10 real changes made)
(120 real changes made)
(1 real change made)
(6 real changes made)
(214 real changes made)
(0 real changes made)
(41 real changes made)
(193 real changes made)
(67 real changes made)
(114 real changes made)
(963 real changes made)
(17 real changes made)
(338 real changes made)
(529 real changes made)
(80 real changes made)
(158 real changes made)
(0 real changes made)
(162 real changes made)
(44 real changes made)
(132 real changes made)
(0 real changes made)
(4 real changes made)
(62 real changes made)
(2 real changes made)
(13 real changes made)
(4 real changes made)
(19 real changes made)
(19 real changes made)
(0 real changes made)
(660 real changes made)
(42 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(8 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(10 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(41 real changes made)
(0 real changes made)
(92 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(4 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(201 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(17 real changes made)
(0 real changes made)
(20 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

. 
. *2. number of tech class that supplier and customer both granted patents
. gen same_num_naics_m = 0

. 
. forvalues i=1(1)286{
  2.         replace same_num_naics_m = same_num_naics_m + 1 if s_num_granted_m`i'
>  >0 & s_num_granted_m`i'!=. & c_num_granted_m`i' >0 & c_num_granted_m`i'!=.
  3. }
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(1 real change made)
(21 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(9 real changes made)
(0 real changes made)
(19 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(60 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(6 real changes made)
(2 real changes made)
(1 real change made)
(0 real changes made)
(3 real changes made)
(398 real changes made)
(4 real changes made)
(9 real changes made)
(4 real changes made)
(5 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(79 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(33 real changes made)
(76 real changes made)
(1 real change made)
(3 real changes made)
(77 real changes made)
(0 real changes made)
(6 real changes made)
(14 real changes made)
(71 real changes made)
(18 real changes made)
(11 real changes made)
(193 real changes made)
(80 real changes made)
(72 real changes made)
(61 real changes made)
(62 real changes made)
(0 real changes made)
(76 real changes made)
(0 real changes made)
(10 real changes made)
(0 real changes made)
(428 real changes made)
(5 real changes made)
(21 real changes made)
(34 real changes made)
(178 real changes made)
(25 real changes made)
(0 real changes made)
(23 real changes made)
(14 real changes made)
(178 real changes made)
(2 real changes made)
(10 real changes made)
(251 real changes made)
(0 real changes made)
(47 real changes made)
(266 real changes made)
(75 real changes made)
(122 real changes made)
(1,189 real changes made)
(25 real changes made)
(489 real changes made)
(757 real changes made)
(98 real changes made)
(416 real changes made)
(0 real changes made)
(329 real changes made)
(108 real changes made)
(238 real changes made)
(0 real changes made)
(9 real changes made)
(194 real changes made)
(2 real changes made)
(26 real changes made)
(6 real changes made)
(34 real changes made)
(23 real changes made)
(0 real changes made)
(894 real changes made)
(76 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(28 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(25 real changes made)
(0 real changes made)
(12 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(135 real changes made)
(0 real changes made)
(182 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(15 real changes made)
(582 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(44 real changes made)
(0 real changes made)
(57 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(7 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)

. 
. *3. number of patents that customers granted in the same industry as the supplie
> r
. 
. gen same_naics_patents_m = 0

. 
. forvalues i=1(1)286{
  2.         
.         replace same_naics_patents_m = same_naics_patents_m + c_num_granted_m`i'
>  if s_num_granted_m`i' >0 & s_num_granted_m`i'!=. & c_num_granted_m`i' >0 & c_nu
> m_granted_m`i'!=.
  3. }
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(1 real change made)
(21 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(9 real changes made)
(0 real changes made)
(19 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(60 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(6 real changes made)
(2 real changes made)
(1 real change made)
(0 real changes made)
(3 real changes made)
(398 real changes made)
(4 real changes made)
(9 real changes made)
(4 real changes made)
(5 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(79 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(33 real changes made)
(76 real changes made)
(1 real change made)
(3 real changes made)
(77 real changes made)
(0 real changes made)
(6 real changes made)
(14 real changes made)
(71 real changes made)
(18 real changes made)
(11 real changes made)
(193 real changes made)
(80 real changes made)
(72 real changes made)
(61 real changes made)
(62 real changes made)
(0 real changes made)
(76 real changes made)
(0 real changes made)
(10 real changes made)
(0 real changes made)
(428 real changes made)
(5 real changes made)
(21 real changes made)
(34 real changes made)
(178 real changes made)
(25 real changes made)
(0 real changes made)
(23 real changes made)
(14 real changes made)
(178 real changes made)
(2 real changes made)
(10 real changes made)
(251 real changes made)
(0 real changes made)
(47 real changes made)
(266 real changes made)
(75 real changes made)
(122 real changes made)
(1,189 real changes made)
(25 real changes made)
(489 real changes made)
(757 real changes made)
(98 real changes made)
(416 real changes made)
(0 real changes made)
(329 real changes made)
(108 real changes made)
(238 real changes made)
(0 real changes made)
(9 real changes made)
(194 real changes made)
(2 real changes made)
(26 real changes made)
(6 real changes made)
(34 real changes made)
(23 real changes made)
(0 real changes made)
(894 real changes made)
(76 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(6 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(28 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(2 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(25 real changes made)
(0 real changes made)
(12 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(135 real changes made)
(0 real changes made)
(182 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(5 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(15 real changes made)
(582 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(9 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(44 real changes made)
(0 real changes made)
(57 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(7 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(3 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1 real change made)
(0 real changes made)

. 
. drop s_num_granted* c_num_granted*

. save "$path2/temp/temp2.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/temp2.dta saved

. 
. 
. 
. 
. ************begin construction of the final variables
. use "$path2/temp/temp2.dta",clear

. *merge in COMPUSTAT fyear, to generate the lag values
. rename sgvkey gvkey_num

. rename srcdate datadate

. merge m:1 gvkey_num datadate using  "$path2/temp/compa_temp1.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                       292,532
        from master                         8  (_merge==1)
        from using                    292,524  (_merge==2)

    Matched                            77,741  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(292,524 observations deleted)

. drop _m

. rename gvkey_num sgvkey

. rename datadate srcdate

. 
. *keep the first 5 customers, same with our previous data /*experiment lever*/
. keep if r_p_salecs_3_1<6
(2,302 observations deleted)

. 
. *sum/average of all customers
. foreach var in same_naics_patents_m{
  2.         *simple sum
.         bys sgvkey srcdate: egen s_`var' = sum(`var')
  3. 
. }

. 
. *collapse the data into sgvkey srcdate level
. duplicates drop sgvkey srcdate, force

Duplicates in terms of sgvkey srcdate

(27,486 observations deleted)

. 
. drop same_cpc_flag same_num_cpc same_cpc_patents same_naics_flag_m same_num_naic
> s_m same_naics_patents_m

. 
. glo all_rsi_pt s_same_naics_patents_m

. 
. *winsorize new vars
. winsor2 $all_rsi_pt , replace cuts (1 99)

. save "$path2/temp/rsi_patent_20221124.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/rsi_patent_20221124.dta saved

. 
. 
. 
. 
. 
. *************************************************************
. *Create Customer level controls
. *************************************************************
. 
. glo path = "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets"

. glo path2 = "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR"

. 
. *number of firms in a sic3_year
. use "$path2/temp/compa_temp.dta",clear

. gen csic3 = int(sic1/10)
(5 missing values generated)

. gen flag = 1

. gen year = year(datadate)

. collapse (sum) num_firms_sic3_yr =flag, by(csic3 year)

. save "$path2/temp/compa_temp_num_firms.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/compa_temp_num_firms.dta saved

. 
. use "$path3/sample_mna_20221217.dta",clear

. 
. keep if STATUS == "Completed"
(3,556 observations deleted)

. *Calculate the total number of M&A in the industry
. keep DATEANN deal_id STATUS counterparty_sic3 sic3 gvkey counterparty_gvkey

. gen id = _n

. gen year = year(DATEANN)

. rename counterparty_sic3 sic3_2

. rename counterparty_gvkey gvkey_2

. rename sic3 sic3_1

. rename gvkey gvkey_1

. reshape long sic3_ gvkey_, i(id) j(ii)
(j = 1 2)

Data                               Wide   ->   Long
-----------------------------------------------------------------------------
Number of observations           70,334   ->   140,668     
Number of variables                   9   ->   8           
j variable (2 values)                     ->   ii
xij variables:
                          sic3_1 sic3_2   ->   sic3_
                        gvkey_1 gvkey_2   ->   gvkey_
-----------------------------------------------------------------------------

. rename sic3_ sic3

. rename gvkey_ gvkey

. 
. drop if sic3 == .
(51,473 observations deleted)

. 
. bys sic3 year: egen num_ma_ind = nvals(deal_id)

. *number of firms involve in the M&A
. bys sic3 year: egen num_ma_ind_firm = nvals(gvkey)

. 
. keep num_ma_ind num_ma_ind_firm sic3 year

. duplicates drop

Duplicates in terms of all variables

(82,362 observations deleted)

. rename sic3 csic3

. xtset csic3 year

Panel variable: csic3 (unbalanced)
 Time variable: year, 1989 to 2019, but with gaps
         Delta: 1 unit

. forvalues i=1(1)3{
  2.         gen num_ma_ind_l`i' = l`i'.num_ma_ind
  3.         replace num_ma_ind_l`i' = 0 if num_ma_ind_l`i' ==.
  4.         gen num_ma_ind_firm_l`i' = l`i'.num_ma_ind_firm
  5.         replace num_ma_ind_firm_l`i' = 0 if num_ma_ind_firm_l`i' ==.
  6. }
(1,316 missing values generated)
(1,316 real changes made)
(1,316 missing values generated)
(1,316 real changes made)
(1,564 missing values generated)
(1,564 real changes made)
(1,564 missing values generated)
(1,564 real changes made)
(1,780 missing values generated)
(1,780 real changes made)
(1,780 missing values generated)
(1,780 real changes made)

. 
. *percentage of M&A in a firm year
. merge 1:1 csic3 year using "$path2/temp/compa_temp_num_firms.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                         7,415
        from master                     1,241  (_merge==1)
        from using                      6,174  (_merge==2)

    Matched                             5,592  (_merge==3)
    -----------------------------------------

. drop if _m == 2
(6,174 observations deleted)

. drop _m

. replace num_firms_sic3_yr = num_ma_ind_firm if num_firms_sic3_yr == .
(1,241 real changes made)

. gen percent_ind_ma = num_ma_ind_firm/num_firms_sic3_yr

. winsor2 percent_ind_ma, cuts(1 99) replace

. xtset csic3 year

Panel variable: csic3 (unbalanced)
 Time variable: year, 1989 to 2019, but with gaps
         Delta: 1 unit

. forvalues i=1(1)3{
  2.         gen percent_ind_ma_l`i' = l`i'.percent_ind_ma
  3.         replace percent_ind_ma_l`i' = 0 if percent_ind_ma_l`i' == .
  4. }
(1,316 missing values generated)
(1,316 real changes made)
(1,564 missing values generated)
(1,564 real changes made)
(1,780 missing values generated)
(1,780 real changes made)

. save "$path2/temp/ma_ind_1.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/ma_ind_1.dta
    saved

. 
. *merge to the supplier-customer-year datasets
. use "$path/seg1208.dta",clear

. *drop duplicates
. duplicates drop sgvkey cgvkey srcdate,force

Duplicates in terms of sgvkey cgvkey srcdate

(0 observations are duplicates)

. keep sgvkey cgvkey year srcdate cdatadate

. duplicates drop

Duplicates in terms of all variables

(0 observations are duplicates)

. *get SIC codes for customers
. rename cgvkey gvkey 

. rename cdatadate datadate

. 
. merge m:1 gvkey datadate using "$path2/temp/compa_temp.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                       324,848
        from master                     4,254  (_merge==1)
        from using                    320,594  (_merge==2)

    Matched                            63,106  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(320,594 observations deleted)

. drop _m

. rename gvkey cgvkey 

. rename datadate cdatadate

. gen csic3 = int(sic1/10)
(4,254 missing values generated)

. drop sic1 srcdate cgvkey cdatadate

. duplicates drop

Duplicates in terms of all variables

(12,501 observations deleted)

. 
. *Now, it is in supplier-customer ind level
. merge m:1 csic3 year using "$path2/temp/ma_ind_1.dta"
(variable csic3 was float, now double to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                        11,990
        from master                     8,657  (_merge==1)
        from using                      3,333  (_merge==2)

    Matched                            46,202  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(3,333 observations deleted)

. drop _m

. 
. replace num_ma_ind = 0 if num_ma_ind == .
(8,657 real changes made)

. replace percent_ind_ma = 0 if percent_ind_ma == .
(8,657 real changes made)

. replace num_ma_ind_firm = 0 if num_ma_ind_firm ==.
(8,657 real changes made)

. forvalues i=1(1)3{
  2.         replace num_ma_ind_l`i' = 0 if num_ma_ind_l`i' ==.
  3.         replace percent_ind_ma_l`i' = 0 if percent_ind_ma_l`i' == .
  4.         replace num_ma_ind_firm_l`i' = 0 if num_ma_ind_firm_l`i' ==.
  5. }
(8,657 real changes made)
(8,657 real changes made)
(8,657 real changes made)
(8,657 real changes made)
(8,657 real changes made)
(8,657 real changes made)
(8,657 real changes made)
(8,657 real changes made)
(8,657 real changes made)

. gen num_ma_ind_past3 = num_ma_ind_l1+ num_ma_ind_l2 + num_ma_ind_l3

. save "$path2/temp/cust_ma_ind_supp_ind_level_1.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/cust_ma_ind_supp_ind_level_1.dta saved

. *collapse into sgvkey year level
. collapse (sum) num_ma_cust_ind = num_ma_ind num_ma_cust_ind_l1 = num_ma_ind_l1 n
> um_ma_cust_ind_l2 = num_ma_ind_l2 num_ma_cust_ind_l3 = num_ma_ind_l3 num_ma_cust
> _ind_past3=num_ma_ind_past3 pct_cust_ma_sum = percent_ind_ma (mean) pct_cust_ma_
> avg = percent_ind_ma , by(sgvkey year)

. save "$path2/temp/cust_ma_ind.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/cust_ma_ind.dta
    saved

. 
. 
. 
. *Customer industry product fluidity
. 
. 
. *get industry for the gvkey-years
. use "$path3/compa78_20_20220410.dta",clear

. destring gvkey, gen(gvkey_num)
gvkey: all characters numeric; gvkey_num generated as long

. drop if at == .
(63,905 observations deleted)

. gen mve = prcc_f*csho
(54,121 missing values generated)

. keep gvkey year sic1

. destring gvkey,replace
gvkey: all characters numeric; replaced as long

. duplicates drop gvkey year,force

Duplicates in terms of gvkey year

(767 observations deleted)

. gen sic3 = int(sic1/10)
(5 missing values generated)

. save "$path2/temp/compa_temp3.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/compa_temp3.dta
    saved

. 
. 
. import delimited "$path/FluidityData/FluidityData.txt", clear 
(encoding automatically selected: ISO-8859-2)
(3 vars, 174,303 obs)

. merge 1:1 gvkey year using "$path2/temp/compa_temp3.dta"
(variable year was int, now double to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                       171,474
        from master                     3,032  (_merge==1)
        from using                    168,442  (_merge==2)

    Matched                           171,271  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(168,442 observations deleted)

. drop _m

. 
. *calculate the average among sic3-year
. collapse (mean) prodmktfluid, by(sic3 year)

. drop if sic3 == .
(33 observations deleted)

. rename sic3 csic3

. save "$path2/temp/fluidity_sic3_yr.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/fluidity_sic3_yr.dta saved

. 
. 
. *merge to the supplier-customer-year datasets
. use "$path/seg1208.dta",clear

. *drop duplicates
. duplicates drop sgvkey cgvkey srcdate,force

Duplicates in terms of sgvkey cgvkey srcdate

(0 observations are duplicates)

. keep sgvkey cgvkey year srcdate cdatadate

. duplicates drop

Duplicates in terms of all variables

(0 observations are duplicates)

. *get SIC codes for customers
. rename cgvkey gvkey 

. rename cdatadate datadate

. 
. merge m:1 gvkey datadate using "$path2/temp/compa_temp.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                       324,848
        from master                     4,254  (_merge==1)
        from using                    320,594  (_merge==2)

    Matched                            63,106  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(320,594 observations deleted)

. drop _m

. rename gvkey cgvkey 

. rename datadate cdatadate

. gen csic3 = int(sic1/10)
(4,254 missing values generated)

. drop sic1 srcdate cgvkey cdatadate

. duplicates drop

Duplicates in terms of all variables

(12,501 observations deleted)

. 
. *Now, it is in supplier-customer ind level
. merge m:1 csic3 year using "$path2/temp/fluidity_sic3_yr.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                         8,036
        from master                     3,998  (_merge==1)
        from using                      4,038  (_merge==2)

    Matched                            50,861  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(4,038 observations deleted)

. drop _m

. 
. *collapse into sgvkey year level
. collapse (sum) cust_fluid_ind=prodmktfluid, by(sgvkey year)

. save "$path2/temp/cust_fluidity.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/cust_fluidity.dta saved

. 
. 
. 
. 
. *Customer industry product similarity: 
. 
. import delimited "$path/TNIC3HHIdata/TNIC3HHIdata.txt", clear 
(encoding automatically selected: UTF-8)
(4 vars, 169,669 obs)

. merge 1:1 gvkey year using "$path2/temp/compa_temp3.dta"
(variable year was int, now double to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                       174,968
        from master                     2,462  (_merge==1)
        from using                    172,506  (_merge==2)

    Matched                           167,207  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(172,506 observations deleted)

. drop _m

. 
. *calculate the average among sic3-year
. collapse (mean) tnic3tsimm, by(sic3 year)

. drop if sic3 == .
(32 observations deleted)

. rename sic3 csic3

. save "$path2/temp/simm_sic3_yr.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/simm_sic3_yr.dta saved

. 
. *merge to the supplier-customer-year datasets
. use "$path/seg1208.dta",clear

. *drop duplicates
. duplicates drop sgvkey cgvkey srcdate,force

Duplicates in terms of sgvkey cgvkey srcdate

(0 observations are duplicates)

. keep sgvkey cgvkey year srcdate cdatadate

. duplicates drop

Duplicates in terms of all variables

(0 observations are duplicates)

. *get SIC codes for customers
. rename cgvkey gvkey 

. rename cdatadate datadate

. 
. merge m:1 gvkey datadate using "$path2/temp/compa_temp.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                       324,848
        from master                     4,254  (_merge==1)
        from using                    320,594  (_merge==2)

    Matched                            63,106  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(320,594 observations deleted)

. drop _m

. rename gvkey cgvkey 

. rename datadate cdatadate

. gen csic3 = int(sic1/10)
(4,254 missing values generated)

. drop sic1 srcdate cgvkey cdatadate

. duplicates drop

Duplicates in terms of all variables

(12,501 observations deleted)

. 
. *Now, it is in supplier-customer ind level
. merge m:1 csic3 year using "$path2/temp/simm_sic3_yr.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                         7,825
        from master                     3,994  (_merge==1)
        from using                      3,831  (_merge==2)

    Matched                            50,865  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(3,831 observations deleted)

. drop _m

. 
. *collapse into sgvkey year level
. collapse (sum) cust_simm_ind=tnic3tsimm, by(sgvkey year)

. save "$path2/temp/cust_simm.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/cust_simm.dta
    saved

. 
end of do-file

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. use "$path3/compa78_20_20220410.dta",clear

. destring gvkey, gen(gvkey_num)
gvkey: all characters numeric; gvkey_num generated as long

. drop if at == .
(63,905 observations deleted)

. gen mve = prcc_f*csho
(54,121 missing values generated)

. keep gvkey sale at ppent mve year

. destring gvkey,replace
gvkey: all characters numeric; replaced as long

. duplicates drop gvkey year,force

Duplicates in terms of gvkey year

(767 observations deleted)

. save "$path2/temp/compa_temp2.dta",replace
file C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR/temp/compa_temp2.dta
    saved

. 
. 
. use "$path/temp/cust_rival_yr_score.dta",clear
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\Datasets/temp/cust_rival_yr_score.dta not found
r(601);

end of do-file

r(601);

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. 
. use "$path3/cust_rival_yr_score.dta",clear
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\Datasets/cust_rival_yr_score.dta not found
r(601);

end of do-file

r(601);

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. 
. use "$path/temp/cust_rival_yr_score.dta",clear
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\Datasets/temp/cust_rival_yr_score.dta not found
r(601);

end of do-file

r(601);

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. 
. glo path = "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\DataConstruction\
> Ziqing\MnA experiment\data"

. glo path2 = "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\JAR"

. glo path3 = "C:\Users\faafrin\Dropbox (CSU Fullerton)\AKRY\Data\Datasets"

. 
end of do-file

. do "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"

. 
. use "$path/temp/cust_rival_yr_score.dta",clear

. * weighted by sales of the rivals
. *merge in compustat
. rename rgvkey gvkey

. merge m:1 gvkey year using "$path2/temp/compa_temp2.dta"
(variable year was int, now double to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                       250,261
        from master                    25,367  (_merge==1)
        from using                    224,894  (_merge==2)

    Matched                         1,034,938  (_merge==3)
    -----------------------------------------

. drop if _m == 2
(224,894 observations deleted)

. drop _m

. rename gvkey rgvkey

. rename at rat

. rename ppent rppent

. rename sale rsale

. rename mve rmve

. 
. foreach weight in  sale{
  2.         *weighted average 
.         bysort cgvkey year: asgen wa_score_`weight' = score , w(r`weight')
  3. 
.         *weighted sum (weighted-average*numbers)
.         gen flag_temp = 0
  4.         *identify those with non-missing data
.         replace flag_temp = 1 if score!=. & r`weight'!=.
  5.         
.         bysort cgvkey year: egen ws_score_`weight' = sum(flag_temp*wa_score_`wei
> ght')
  6.         drop flag_temp
  7. }
(1,030,291 real changes made)

. 
. *collapse into cgvkey year level
. collapse (mean)  wa_score_sale ws_score_sale, by(cgvkey year)

. save "$path2/temp/customer_yr_weightedscore.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/customer_yr_weightedscore.dta saved

. 
. 
. *collapse into the supplier-year level , sum the customer level data to get to t
> he supplier level for our analysis.
. use "$path3/seg1208.dta",clear

. merge m:1 cgvkey year using "$path2/temp/customer_yr_weightedscore.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                        11,806
        from master                    11,806  (_merge==1)
        from using                          0  (_merge==2)

    Matched                            55,554  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(0 observations deleted)

. drop _m

. 
. collapse (sum) wa_score_sale ws_score_sale, by(sgvkey srcdate)

. 
. use "$path3/seg1208.dta",clear

. merge m:1 cgvkey year using "$path2/temp/customer_yr_weightedscore.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                        11,806
        from master                    11,806  (_merge==1)
        from using                          0  (_merge==2)

    Matched                            55,554  (_merge==3)
    -----------------------------------------

. 
. drop if _m == 2
(0 observations deleted)

. drop _m

. 
. rename ws_score_sale ws_score

. foreach weight in p_salecs{
  2.         bysort sgvkey srcdate: asgen wa_score_`weight' = ws_score , w(`weight
> ')
  3. 
.         gen flag_temp = 0
  4.         replace flag_temp = 1 if ws_score!=. & `weight'!=.
  5.         
.         bysort sgvkey srcdate: egen ws_score_`weight' = sum(flag_temp*wa_score_`
> weight')
  6.         drop flag_temp
  7. }
(55,554 real changes made)

. duplicates drop sgvkey srcdate,force

Duplicates in terms of sgvkey srcdate

(28,246 observations deleted)

. save "$path2/temp/supplier_yr_weightedscore_w.dta",replace
file C:\Users\faafrin\Dropbox (CSU
    Fullerton)\AKRY\Data\JAR/temp/supplier_yr_weightedscore_w.dta saved

. 
end of do-file

. run "C:\Users\faafrin\AppData\Local\Temp\STD3c4c_000000.tmp"
. exit, clear
    