--------------------------------------------------------------------------------------------------------
       log:  D:\Data\share\boehmke2009jop\boehmke2009jop-mkdata.log
  log type:  text
 opened on:   9 Jun 2010, 16:06:21

. /*      ****************************************************************        */
> /*      File Name:      boehmke2009jop-mkdata.do                                */
> /*      Date:           June 08, 2010                                           */
> /*      Author:         Frederick J. Boehmke                                    */
> /*      Purpose:        This file creates the data set for the analysis of      */
> /*                      the directed dyad approach to state policy adoption     */
> /*                      using end of life pain-management data.                 */
> /*      Input File:     boehmke2009jop.csv                                      */
> /*      Output File:    boehmke2009jop-mkdata.log,                              */
> /*                      boehmke2009jop.dta,                                     */
> /*                      boehmke2009jop-bycomponent.dta                          */
> /*      Requires:       nbrs-code-dyads.ado.                                    */
> /*      Version:        Stata 9 or above.                                       */
> /*      ****************************************************************        */
> 
> 
>         /********************************************************/
>         /* This program takes the original state data set and   */
>         /* creates the directed dyad data set.                  */
>         /********************************************************/
> 
>         
> program drop _all;

.         program define mkdyads;
  1.         foreach var of varlist _all {;
  2.           rename `var' `var'_02;
  3.           };
  4.         rename year_02 year;
  5.         rename time_02 time;
  6.         rename fsmbgde_02 fsmbgde;
  7.         rename time_prefsmb_02 time_prefsmb;
  8.         rename time_pstfsmb_02 time_pstfsmb;
  9.         sort year stateno_02;
 10.         save boehmke2009jop-mkdyad, replace;
 11.   use boehmke2009jop, clear;
 12.         expand 50;
 13.         foreach var of varlist _all {;
 14.           rename `var' `var'_01;
 15.           };
 16.         rename year_01 year;
 17.         rename time_01 time;
 18.         rename fsmbgde_01 fsmbgde;
 19.         rename time_prefsmb_01 time_prefsmb;
 20.         rename time_pstfsmb_01 time_pstfsmb;
 21.         sort year stateno_01;
 22.         generate stateno_02 = 1;
 23.   quietly by year stateno_01: replace stateno_02 = stateno_02[_n-1] + 1 
>         if stateno_01==stateno_01[_n-1] & year==year[_n-1];
 24.   sort year stateno_02;
 25.   joinby year stateno_02 using boehmke2009jop-mkdyad;
 26.   save boehmke2009jop, replace;
 27.     erase boehmke2009jop-mkdyad.dta;
 28. end;

.         /********************************************************/
>         /* Open the monadic data set and create the dyadic data.*/
>         /********************************************************/
> 
> 
> insheet using boehmke2009jop.csv, clear;
(17 vars, 800 obs)

.                 /* Create a few variables. */
> 
>   generat time = year - 1989;

.   replace time = . if year < 1989;
(100 real changes made, 100 to missing)

.   tsset stateno year;
       panel variable:  stateno (strongly balanced)
        time variable:  year, 1987 to 2002
                delta:  1 unit

.     generat time_prefsmb = time*(year <  1999);
(100 missing values generated)

.   generat time_pstfsmb = time*(year >= 1999);
(100 missing values generated)

.   egen     prov_num = rowtotal(prov2-prov8);

.   by stateno: generate prov_tot = sum(prov_num);

.   generate prov_any = (prov_num >= 1);

.                 /* Did the state adopt each provision by the previous year? */
>   
>   forvalues num=2/8 {;
  2.         generat prov_lag_`num' = 0;
  3.         replace prov_lag_`num' = 1 if l.prov`num' == 1 & stateno==l.stateno;
  4.         replace prov_lag_`num' = 1 if l.prov_lag_`num' == 1 & stateno==l.stateno;
  5.         };
(27 real changes made)
(84 real changes made)
(30 real changes made)
(101 real changes made)
(26 real changes made)
(84 real changes made)
(28 real changes made)
(86 real changes made)
(24 real changes made)
(77 real changes made)
(26 real changes made)
(79 real changes made)
(18 real changes made)
(38 real changes made)

.                 /* Did the state adopt each provision by the current year? */
>   
>   forvalues num=2/8 {;
  2.         generat prov_has_`num' = 0;
  3.         replace prov_has_`num' = 1 if prov`num' == 1;
  4.         by stateno: replace prov_has_`num' = l.prov_has_`num' if l.prov_has_`num' == 1;
  5.                 };
(27 real changes made)
(111 real changes made)
(30 real changes made)
(131 real changes made)
(26 real changes made)
(110 real changes made)
(28 real changes made)
(114 real changes made)
(24 real changes made)
(101 real changes made)
(26 real changes made)
(105 real changes made)
(19 real changes made)
(56 real changes made)

.                 /* Call the program to turn the monadic data into dyadic data. */
>         
>   save boehmke2009jop, replace;
file boehmke2009jop.dta saved

.   mkdyads;
file boehmke2009jop-mkdyad.dta saved
(39200 observations created)
file boehmke2009jop.dta saved

.         /****************************************************************/
>         /* Create dyad-level variables including emulation variables.   */
>         /****************************************************************/
>         
>   
>                 /* Create dyad id variable. */
>   
>   egen dyad = group(state_01 state_02);

.   tsset dyad year;
       panel variable:  dyad (strongly balanced)
        time variable:  year, 1987 to 2002
                delta:  1 unit

.                 /* How many components does state 01 not currently have */
>                 /* the same values for as state 02 had last year?       */
> 
>   generat emul_diff = 
>         (prov_has_2_01 != prov_lag_2_02) + (prov_has_3_01 != prov_lag_3_02) + 
>         (prov_has_4_01 != prov_lag_4_02) + (prov_has_5_01 != prov_lag_5_02) + 
>         (prov_has_6_01 != prov_lag_6_02) + (prov_has_7_01 != prov_lag_7_02) + 
>         (prov_has_8_01 != prov_lag_8_02) if year>1989;
(7500 missing values generated)

.                 /* How many components did state 01 not have    */
>                 /* the same values as state 02 had last year?   */
> 
>   generat emul_diff_lag = 
>         (prov_lag_2_01 != prov_lag_2_02) + (prov_lag_3_01 != prov_lag_3_02) + 
>         (prov_lag_4_01 != prov_lag_4_02) + (prov_lag_5_01 != prov_lag_5_02) + 
>         (prov_lag_6_01 != prov_lag_6_02) + (prov_lag_7_01 != prov_lag_7_02) + 
>         (prov_lag_8_01 != prov_lag_8_02) if year>1989;
(7500 missing values generated)

.                 /* Did the number of components with different values   */
>                 /* decrease? If so, then state 01 emulated state 02.    */
>                 /* Then remove observations with all 7 adopted.         */
>                 
>   by dyad: generat emul_net = (abs(emul_diff) < abs(emul_diff_lag)) if year>1989;
(7500 missing values generated)

.   replace  emul_net = . if l.prov_tot_01==7;
(1800 real changes made, 1800 to missing)

.                 /* Did state 02 have any component that state 01 did    */
>                 /* not last year? If so, then state 01 has the          */
>                 /* opportunity to emulate state 02.                     */
>   
>   generat emul_opp_net = 
>         (prov_lag_2_01 == 0 & prov_lag_2_02 == 1) + (prov_lag_3_01 == 0 & prov_lag_3_02 == 1) + 
>         (prov_lag_4_01 == 0 & prov_lag_4_02 == 1) + (prov_lag_5_01 == 0 & prov_lag_5_02 == 1) + 
>         (prov_lag_6_01 == 0 & prov_lag_6_02 == 1) + (prov_lag_7_01 == 0 & prov_lag_7_02 == 1) + 
>         (prov_lag_8_01 == 0 & prov_lag_8_02 == 1) if year>1989;
(7500 missing values generated)

.         recode emul_opp_net 1/max=1;
(emul_opp_net: 5510 changes made)

.           keep mb* rpcpinc* ideology* prov* emul* fsmb* year* state* time* dyad;

.         /********************************************************/
>         /* Create the relative variables measures.              */
>         /********************************************************/
> 
> 
>   foreach var of newlist rpcpinc ideology mblegal mbautho mbnonmd {;
  2.         generat `var'_diff = abs(`var'_01 - `var'_02);
  3.         };
(3136 missing values generated)
(5774 missing values generated)
(5774 missing values generated)
(5774 missing values generated)

.         /********************************************************/
>         /* Create the neighbors variable and associated         */
>         /* measures of adoption.                                */
>         /********************************************************/
> 
>                 /* This program creates an indicator for        */
>                 /* whether two states are contiguous.           */
> 
>   do nbrs-code-dyads.do;

. #delimit;
delimiter now ;
.         /* **************************************************************************** */
>         /* File:        nbr-code.do                                                     */
>         /* Author:      Frederick J. Boehmke                                            */
>         /* Date:        August 25, 2001                                                 */
>         /* Purpose:     STATA do-file to be called by some other do-file (or manually). */
>         /*                                                                              */
>         /* This code constructs variable measuring the number of neighboring states     */
>         /*      adoption of some policy.  If you want it lagged, do that after it is    */
>         /*      created.                                                                */
>         /* Must be sorted by stateno (which is very specific - based on sort by full).  */
>         /*      state name, NOT abbreviation).                                          */
>         /* Coding taking from Berry and Berry's 1990 AJPS article.                      */
>         /* **************************************************************************** */
>         /* File:        nbr-code-dyads.do                                               */
>         /* Author:      Frederick J. Boehmke                                            */
>         /* Date:        June 09, 2006                                                   */
>         /* Purpose:     Identify contiguous states in dyadic data set. No sorting       */
>         /*              necessary in dyadic form.                                       */
>         /*                                                                              */
>         /* Coding taking from Berry and Berry's 1990 AJPS article.                      */
>         /* **************************************************************************** */
> 
> gen nbr = 0;

. replace nbr =   1 if (stateno_02 == stateno_01 + 08 | stateno_02 == stateno_01 + 09 | stateno_02 == st
> ateno_01 + 23 | stateno_02 == stateno_01 + 41)     & stateno_01 == 1;
(64 real changes made)

. replace nbr =   0 if  stateno_01 == 2;
(0 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 03 | stateno_02 == stateno_01 + 02 | stateno_02 == st
> ateno_01 + 28 | stateno_02 == stateno_01 + 25 | stateno_02 == stateno_01 + 41)     & stateno_01 == 3;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 14 | stateno_02 == stateno_01 + 39 | stateno_02 == st
> ateno_01 + 32 | stateno_02 == stateno_01 + 21 | stateno_02 == stateno_01 + 13 | stateno_02 == stateno_
> 01 + 38 | stateno_02 == stateno_01 + 20)     & stateno_01 == 4;
(112 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 02 | stateno_02 == stateno_01 + 23 | stateno_02 == st
> ateno_01 + 32)     & stateno_01 == 5;
(48 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 03 | stateno_02 == stateno_01 + 25 | stateno_02 == st
> ateno_01 + 38 | stateno_02 == stateno_01 + 44 | stateno_02 == stateno_01 + 10 | stateno_02 == stateno_
> 01 + 21 | stateno_02 == stateno_01 + 30)     & stateno_01 == 6;
(112 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 14 | stateno_02 == stateno_01 + 25 | stateno_02 == st
> ateno_01 + 32)     & stateno_01 == 7;
(48 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 12 | stateno_02 == stateno_01 + 30 | stateno_02 == st
> ateno_01 + 22)     & stateno_01 == 8;
(48 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 08 | stateno_02 == stateno_01 + 01)     & stateno_01 
> == 9;
(32 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 01 | stateno_02 == stateno_01 - 09 | stateno_02 == st
> ateno_01 + 32 | stateno_02 == stateno_01 + 30 | stateno_02 == stateno_01 + 23)     & stateno_01 == 10;
(80 real changes made)

. replace nbr =   0 if  stateno_01 == 11;
(0 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 35 | stateno_02 == stateno_01 + 25 | stateno_02 == st
> ateno_01 + 16 | stateno_02 == stateno_01 + 32 | stateno_02 == stateno_01 + 38 | stateno_02 == stateno_
> 01 + 14)     & stateno_01 == 12;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 36 | stateno_02 == stateno_01 + 02 | stateno_02 == st
> ateno_01 + 12 | stateno_02 == stateno_01 + 04 | stateno_02 == stateno_01 + 01 | stateno_02 == stateno_
> 01 + 09)     & stateno_01 == 13;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 03 | stateno_02 == stateno_01 - 01 | stateno_02 == st
> ateno_01 + 08 | stateno_02 == stateno_01 + 21)     & stateno_01 == 14;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 10 | stateno_02 == stateno_01 + 12 | stateno_02 == st
> ateno_01 + 26 | stateno_02 == stateno_01 + 08 | stateno_02 == stateno_01 + 34 | stateno_02 == stateno_
> 01 - 02)     & stateno_01 == 15;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 20 | stateno_02 == stateno_01 - 10 | stateno_02 == st
> ateno_01 + 11 | stateno_02 == stateno_01 + 09)     & stateno_01 == 16;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 13 | stateno_02 == stateno_01 + 25 | stateno_02 == st
> ateno_01 - 04 | stateno_02 == stateno_01 - 03 | stateno_02 == stateno_01 + 08 | stateno_02 == stateno_
> 01 + 18 | stateno_02 == stateno_01 + 29 | stateno_02 == stateno_01 + 31)     & stateno_01 == 17;
(128 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 25 | stateno_02 == stateno_01 - 14 | stateno_02 == st
> ateno_01 + 06)     & stateno_01 == 18;
(48 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 10 | stateno_02 == stateno_01 + 02)     & stateno_01 
> == 19;
(32 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 26 | stateno_02 == stateno_01 + 28 | stateno_02 == st
> ateno_01 + 18 | stateno_02 == stateno_01 - 12 | stateno_02 == stateno_01 + 10)     & stateno_01 == 20;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 18 | stateno_02 == stateno_01 - 14 | stateno_02 == st
> ateno_01 + 11 | stateno_02 == stateno_01 + 08 | stateno_02 == stateno_01 - 02 | stateno_02 == stateno_
> 01 + 24)     & stateno_01 == 21;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 27 | stateno_02 == stateno_01 + 01 | stateno_02 == st
> ateno_01 - 08 | stateno_02 == stateno_01 - 13)     & stateno_01 == 22;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 11 | stateno_02 == stateno_01 + 18 | stateno_02 == st
> ateno_01 - 08 | stateno_02 == stateno_01 + 26 | stateno_02 == stateno_01 - 01)     & stateno_01 == 23;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 06 | stateno_02 == stateno_01 - 23 | stateno_02 == st
> ateno_01 + 18 | stateno_02 == stateno_01 - 20)     & stateno_01 == 24;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 21 | stateno_02 == stateno_01 + 11 | stateno_02 == st
> ateno_01 - 09 | stateno_02 == stateno_01 + 02 | stateno_02 == stateno_01 - 10 | stateno_02 == stateno_
> 01 - 12 | stateno_02 == stateno_01 - 08 | stateno_02 == stateno_01 + 17)     & stateno_01 == 25;
(128 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 14 | stateno_02 == stateno_01 + 24 | stateno_02 == st
> ateno_01 + 15 | stateno_02 == stateno_01 + 08)     & stateno_01 == 26;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 11 | stateno_02 == stateno_01 - 21 | stateno_02 == st
> ateno_01 + 23 | stateno_02 == stateno_01 + 14 | stateno_02 == stateno_01 - 12 | stateno_02 == stateno_
> 01 - 02)     & stateno_01 == 27;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 23 | stateno_02 == stateno_01 + 09 | stateno_02 == st
> ateno_01 - 16 | stateno_02 == stateno_01 + 16 | stateno_02 == stateno_01 - 25)     & stateno_01 == 28;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 08 | stateno_02 == stateno_01 + 16 | stateno_02 == st
> ateno_01 - 10)     & stateno_01 == 29;
(48 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 22 | stateno_02 == stateno_01 + 08 | stateno_02 == st
> ateno_01 + 02 | stateno_02 == stateno_01 - 10)     & stateno_01 == 30;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 28 | stateno_02 == stateno_01 + 13 | stateno_02 == st
> ateno_01 - 25 | stateno_02 == stateno_01 + 05 | stateno_02 == stateno_01 + 12)     & stateno_01 == 31;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 06 | stateno_02 == stateno_01 - 02 | stateno_02 == st
> ateno_01 - 25 | stateno_02 == stateno_01 - 11 | stateno_02 == stateno_01 + 13)     & stateno_01 == 32;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 07 | stateno_02 == stateno_01 - 23 | stateno_02 == st
> ateno_01 + 09 | stateno_02 == stateno_01 + 13)     & stateno_01 == 33;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 07 | stateno_02 == stateno_01 - 08 | stateno_02 == st
> ateno_01 - 11)     & stateno_01 == 34;
(48 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 18 | stateno_02 == stateno_01 - 21 | stateno_02 == st
> ateno_01 - 13 | stateno_02 == stateno_01 + 03 | stateno_02 == stateno_01 + 13)     & stateno_01 == 35;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 + 07 | stateno_02 == stateno_01 - 05 | stateno_02 == st
> ateno_01 - 30 | stateno_02 == stateno_01 - 20 | stateno_02 == stateno_01 - 11 | stateno_02 == stateno_
> 01 - 32)     & stateno_01 == 36;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 32 | stateno_02 == stateno_01 - 09 | stateno_02 == st
> ateno_01 - 25 | stateno_02 == stateno_01 + 10)     & stateno_01 == 37;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 30 | stateno_02 == stateno_01 - 18 | stateno_02 == st
> ateno_01 + 10 | stateno_02 == stateno_01 - 03 | stateno_02 == stateno_01 - 06 | stateno_02 == stateno_
> 01 - 08)     & stateno_01 == 38;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 32 | stateno_02 == stateno_01 - 18)     & stateno_01 
> == 39;
(32 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 30 | stateno_02 == stateno_01 - 07)     & stateno_01 
> == 40;
(32 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 07 | stateno_02 == stateno_01 - 14 | stateno_02 == st
> ateno_01 + 09 | stateno_02 == stateno_01 - 15 | stateno_02 == stateno_01 - 18 | stateno_02 == stateno_
> 01 - 26)     & stateno_01 == 41;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 09 | stateno_02 == stateno_01 - 32 | stateno_02 == st
> ateno_01 - 41 | stateno_02 == stateno_01 - 18 | stateno_02 == stateno_01 - 38 | stateno_02 == stateno_
> 01 - 17 | stateno_02 == stateno_01 - 25 | stateno_02 == stateno_01 + 04)     & stateno_01 == 42;
(128 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 12 | stateno_02 == stateno_01 - 07 | stateno_02 == st
> ateno_01 - 39 | stateno_02 == stateno_01 - 25)     & stateno_01 == 43;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 41 | stateno_02 == stateno_01 - 16 | stateno_02 == st
> ateno_01 - 32 | stateno_02 == stateno_01 + 06 | stateno_02 == stateno_01 - 38 | stateno_02 == stateno_
> 01 - 13)     & stateno_01 == 44;
(96 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 16 | stateno_02 == stateno_01 - 24 | stateno_02 == st
> ateno_01 - 13)     & stateno_01 == 45;
(48 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 13 | stateno_02 == stateno_01 - 04 | stateno_02 == st
> ateno_01 - 29 | stateno_02 == stateno_01 + 02 | stateno_02 == stateno_01 - 26)     & stateno_01 == 46;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 10 | stateno_02 == stateno_01 - 35)     & stateno_01 
> == 47;
(32 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 02 | stateno_02 == stateno_01 - 31 | stateno_02 == st
> ateno_01 - 13 | stateno_02 == stateno_01 - 10 | stateno_02 == stateno_01 - 28)     & stateno_01 == 48;
(80 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 26 | stateno_02 == stateno_01 - 34 | stateno_02 == st
> ateno_01 - 36 | stateno_02 == stateno_01 - 27)     & stateno_01 == 49;
(64 real changes made)

. replace nbr =   1 if (stateno_02 == stateno_01 - 44 | stateno_02 == stateno_01 - 06 | stateno_02 == st
> ateno_01 - 38 | stateno_02 == stateno_01 - 24 | stateno_02 == stateno_01 - 09 | stateno_02 == stateno_
> 01 - 23)     & stateno_01 == 50;
(96 real changes made)

. 
end of do-file

.                 /* Then multiply whether state 02 has the       */
>                 /* component by whether state 02 is a neighbor. */
>   
>   forvalues provno=2/8 {;
  2.         generat nbr_lag_`provno' = nbr*prov_lag_`provno'_02;
  3.         egen    nbrs_lag_`provno' = total(nbr_lag_`provno'), by(stateno_01 year);
  4.         };

.   generat nbr_lag_any = max(nbr_lag_2, nbr_lag_3, nbr_lag_4, nbr_lag_5, nbr_lag_6, nbr_lag_7, nbr_lag_
> 8);

.   egen    nbr_lag_sum = rowtotal(nbr_lag_2 nbr_lag_3 nbr_lag_4 nbr_lag_5 nbr_lag_6 nbr_lag_7 nbr_lag_8
> );

.   egen    nbrs_lag_any = total(nbr_lag_any), by(stateno_01 year);

.   egen    nbrs_lag_sum = total(nbr_lag_sum), by(stateno_01 year);

.         /********************************************************/
>         /* Drop intermediary variables for each component.      */
>         /********************************************************/
> 
>         
> drop    prov_lag_2_01-prov_has_8_01 
>         prov_lag_2_02-prov_has_8_02 
>         prov2_01-prov8_01 
>         prov2_02-prov8_02  
>         nbr_lag_2-nbrs_lag_8
>         emul_diff emul_diff_lag;

.         /********************************************************/
>         /* Label variables and data set.                        */
>         /********************************************************/
> 
> 
>   label data "Dyadic data set with state pain management emulations (F. Boehmke)";

.         label variable mblegal_01       "MB Legal Counsel - State 01";

.         label variable mblegal_02       "MB Legal Counsel - State 02";

.         label variable mblegal_diff     "MB Legal Counsel - Difference";

.         label variable mbnonmd_01       "MB Non-M.D. Members - State 01";

.         label variable mbnonmd_02       "MB Non-M.D. Members - State 02";

.         label variable mbnonmd_diff     "MB Non-M.D. Members - Difference";

.         label variable mbautho_01       "MB Authorization - State 01";

.         label variable mbautho_02       "MB Authorization - State 02";

.         label variable mbautho_diff     "MB Authorization - Difference";

.         label variable rpcpinc_01       "Income - State 01";

.         label variable rpcpinc_02       "Income - State 02";

.         label variable rpcpinc_diff     "Income - Difference";

.         label variable ideology_01      "Liberal Ideology - State 01";

.         label variable ideology_02      "Liberal Ideology - State 02";

.         label variable ideology_diff    "Liberal Ideology - Difference";

.         label variable nbr_lag_sum      "Total Provisions - State 02 Contiguous";

.         label variable nbrs_lag_sum     "Total Provisions - Contiguous States";

.         label variable prov_tot_02      "Total Provisions - State 02";

.         order dyad year state_01 stateno_01 statenam_01 state_02 stateno_02 statenam_02 
>           emul* *_01 *_02 *_diff nbr*;

.                 compress;
dyad was float now int
stateno_02 was float now byte
emul_net was float now byte
emul_opp_net was float now byte
prov_num_01 was float now byte
prov_tot_01 was float now byte
prov_any_01 was float now byte
prov_num_02 was float now byte
prov_tot_02 was float now byte
prov_any_02 was float now byte
mbautho_diff was float now byte
nbr was float now byte
nbr_lag_any was float now byte
nbr_lag_sum was float now byte
nbrs_lag_any was float now byte
nbrs_lag_sum was float now byte
time was float now byte
time_prefsmb was float now byte
time_pstfsmb was float now byte

. save boehmke2009jop, replace;
file boehmke2009jop.dta saved

. log close;
       log:  D:\Data\share\boehmke2009jop\boehmke2009jop-mkdata.log
  log type:  text
 closed on:   9 Jun 2010, 16:06:26
--------------------------------------------------------------------------------------------------------
