/*SAS Input Statements for External Cause of Injury Morbidity Matrix */

/*Following are the SAS statements containing ICD-9 CM codes to be used to program the external cause of injury morbidity matrix.
Please cut and paste the SAS codes provided into your SAS programs.

The following 2 modifications were made on March 15,2007: 1) E979.6 and 
E979.7 were moved to the Poisoning, assault category and removed from 
Other specifiable and classifiable to be consistent with the placement of similar terrorism codes used in ICD-10 external cause mortality matrix, and 2) E999 was separated into E999.0 and E999.1 with 
E999.1,late effects of injury due to terrorism, moved to the assault
category where the other terrorism codes, E979.0-.9, are located from the Other category.

On Jan 29,2009, the SAS code has been checked against the December 1, 2008 updated Martix. (accessed on line at http://www.cdc.gov/ncipc/osp/matrix2.htm)
The following modification was made: E928.6 "Environmental exposure to 
harmful algae and toxins" was added to other specified and classifiable. 

Variable names used in the SAS statements 
CAUSEDET: 3 DIGIT ICD CODE fields for morbidity data
CAUSEDT4: 4 DIGIT ICD CODE field for morbidity data
PERSINJ:  4TH DIGIT OF THE ICD CODE - ONLY FOR MVT (810-819 CODES) */

data Matrix9E;
set yourdata;

 LABEL CAUSE='MECHANISM/CAUSE'
       INJ='MANNER/INTENT'       ;

   /* EXTERNAL CAUSE CODING MATRIX FOR INJURY MORBIDITY DATA*/

   /* MECHANISM-CAUSE CODING */

   /*CAUSE=MVT*/
   IF (CAUSEDET GE 810 AND CAUSEDET LE 819) OR 
	   CAUSEDT4 = 9585 OR CAUSEDT4 = 9685 OR CAUSEDT4 = 9885 THEN 
MVT=1;

   IF MVT=1 THEN CAUSE=1;

		 /*Person Type in MVT*/
   			/*OCCUPANT*/
	     IF (CAUSEDET GE 810 AND CAUSEDET LE 819) AND
   			(PERSINJ=0 OR PERSINJ=1) THEN MVTPER=1;
			/*MC*/
 		 IF (CAUSEDET GE 810 AND CAUSEDET LE 819) AND
   			(PERSINJ=2 OR PERSINJ=3) THEN MVTPER=2;
			/*PEDAL*/
  		 IF (CAUSEDET GE 810 AND CAUSEDET LE 819) AND 
			PERSINJ=6 THEN MVTPER=3;
			/*PEDEST*/
  		 IF (CAUSEDET GE 810 AND CAUSEDET LE 819) AND 
			PERSINJ=7 THEN MVTPER=4;
			/*UNKNOWN*/
  		 IF (CAUSEDET GE 810 AND CAUSEDET LE 819) AND 
			PERSINJ=9 THEN MVTPER=5;
			/*OTHER*/
  		 IF (CAUSEDET GE 810 AND CAUSEDET LE 819) AND
  		    (PERSINJ=4 OR PERSINJ=5 OR PERSINJ=8) THEN MVTPER=6;

  /*CAUSE=OTHER PEDAL CYC*/
  IF (CAUSEDET GE 800 AND CAUSEDET LE 807) AND PERSINJ=3 THEN NTB=1;
  IF (CAUSEDET GE 820 AND CAUSEDET LE 825) AND PERSINJ=6 THEN NTB=2;
  IF CAUSEDT4=8261 OR CAUSEDT4=8269 THEN NTB=3;
  IF (CAUSEDET GE 827 AND CAUSEDET LE 829) AND PERSINJ=1 THEN NTB=4;
  IF NTB GE 1 AND NTB LE 4 THEN OTHPEDAL=1;

  IF OTHPEDAL=1 THEN CAUSE=11;

  /*COUNT ALL PEDAL CYC; NOT INLCUDED AS ONE OF THE CAUSE*/
  IF MVCPER=3 OR OTHPEDAL=1 THEN PEDALALL=1;

  /*CAUSE=OTHER PEDESTRIAN*/
  IF (CAUSEDET GE 800 AND CAUSEDET LE 807) AND (PERSINJ=2) THEN 
PEDEST=1;
  IF (CAUSEDET GE 820 AND CAUSEDET LE 825) AND (PERSINJ=7) THEN 
PEDEST=2;
  IF (CAUSEDET GE 826 AND CAUSEDET LE 829) AND (PERSINJ=0) THEN 
PEDEST=3;
  IF PEDEST =1 OR PEDEST=2 OR PEDEST=3 THEN OTHPEDST=1;

  IF OTHPEDST=1 THEN CAUSE=12;
  /*CAUSE=OTHER TRANS*/
  IF (CAUSEDET GE 800 AND CAUSEDET LE 807) AND (PERSINJ=0 OR
  	  PERSINJ=1 OR PERSINJ=8 OR PERSINJ=9) THEN OT=1;
  IF  CAUSEDET=826 AND (PERSINJ GE 2 AND PERSINJ LE 8) THEN OT=2;
  IF ((CAUSEDET GE 827 AND CAUSEDET LE 829) AND
  	 (PERSINJ GE 2 AND PERSINJ LE 9)) OR CAUSEDET=831 OR 
	 (CAUSEDET GE 833 AND CAUSEDET LE 845) THEN OT=3;
  IF (CAUSEDET GE 820 AND CAUSEDET LE 825) AND ((PERSINJ GE 0 AND
  	  PERSINJ LE 5) OR (PERSINJ=8 OR PERSINJ=9)) THEN OT=4;
  IF CAUSEDT4=9586 OR CAUSEDT4=9886 THEN OT=5;

  IF OT =1 OR OT=2 OR OT=3 OR OT=4 OR OT=5 THEN OTHTRANS=1;

  IF OTHTRANS=1 THEN CAUSE=13;

  /*CAUSE=FIREARM*/
  IF (CAUSEDT4 GE 9220 and CAUSEDT4 LE 9223) OR CAUSEDT4=9228 OR 
CAUSEDT4=9229 OR 
	 (CAUSEDT4 GE 9550 AND CAUSEDT4 LE 9554) OR
	 (CAUSEDT4 GE 9650 AND CAUSEDT4 LE 9654) OR 
	  CAUSEDET = 970 OR
	 (CAUSEDT4 GE 9850 AND CAUSEDT4 LE 9854) OR
 	  CAUSEDT4 = 9794 THEN FIREARM=1;

  IF FIREARM=1 THEN CAUSE=2;

  /*CAUSE=POISONING*/
  IF (CAUSEDET GE 850 AND CAUSEDET LE 869) OR
	 (CAUSEDET GE 950 AND CAUSEDET LE 952) OR
	  CAUSEDET =962 OR CAUSEDET = 972 OR
  	 (CAUSEDET GE 980 AND CAUSEDET LE 982) OR (CAUSEDT4=9796 OR
CAUSEDT4=9797) THEN POISON=1;

  IF POISON=1 THEN CAUSE=3;

  /*CAUSE=FALLS*/
  IF (CAUSEDET GE 880 AND CAUSEDET LE 886) OR 
	  CAUSEDET = 888 OR 
	  CAUSEDET = 957 OR 
	  CAUSEDT4 = 9681 OR
	  CAUSEDET = 987  THEN FALL=1;

  IF FALL=1 THEN CAUSE=4;

  /*CAUSE=SUFFOCATION*/
  IF CAUSEDET = 911 OR CAUSEDET = 912 OR CAUSEDET=913 OR
	 CAUSEDET = 953 OR 
	 CAUSEDET = 963 OR 
	 CAUSEDET = 983 THEN SUFFOC=1;

  IF SUFFOC=1 THEN CAUSE=5;

  /*CAUSE=DROWNING*/
  IF CAUSEDET = 830 OR CAUSEDET = 832 OR 
	 CAUSEDET = 910 OR
	 CAUSEDET = 954 OR 
	 CAUSEDET = 964  OR 
	 CAUSEDET = 984 THEN DROWNING=1;

  IF DROWNING=1 THEN CAUSE=6;

  /*CAUSE=FIRE/BURN*/
  IF (CAUSEDET GE 890 AND CAUSEDET LE 899) OR
	  CAUSEDT4 = 9581 OR
	  CAUSEDT4 = 9680 OR 
	  CAUSEDT4 = 9881 OR 
 	  CAUSEDT4 = 9793 THEN FIRE =1;

  IF CAUSEDET = 924 OR 
	 CAUSEDT4 = 9582 OR CAUSEDT4 = 9587 OR
  	 CAUSEDET = 961 OR CAUSEDT4 = 9683 OR 
	 CAUSEDT4 = 9882 OR CAUSEDT4 = 9887 THEN BURN=1;

  IF FIRE=1 OR BURN =1 THEN FIREBURN=1;

  IF FIREBURN=1 THEN CAUSE=7;

  /*CAUSE=CUT/PIERCE*/
  IF CAUSEDET = 920 OR 
	 CAUSEDET = 956 OR 
	 CAUSEDET = 966 OR
	 CAUSEDET = 974 OR 
	 CAUSEDET = 986 THEN CUT=1;

  IF CUT=1 THEN CAUSE=8;

  /*CAUSE=STRUCK BY/AGAINST*/
  IF CAUSEDET = 916 OR CAUSEDET = 917 OR
	 CAUSEDT4 = 9682 OR CAUSEDT4 = 9600 OR
	 CAUSEDET = 973 OR CAUSEDET=975 THEN STRUCK=1;

  IF STRUCK=1 THEN CAUSE=9;

  /*CAUSE=MACHINERY*/
  IF CAUSEDET = 919 THEN MACH=1;

  IF MACH=1 THEN CAUSE=10;

  /*CAUSE=NATURAL/ENVIR*/
  IF (CAUSEDET GE 900 AND CAUSEDET LE 909) OR
	  CAUSEDT4 = 9280 OR CAUSEDT4 = 9281 OR CAUSEDT4= 9282 OR
	  CAUSEDT4 = 9583 OR CAUSEDT4 = 9883 THEN NATENV=1;

  IF NATENV=1 THEN CAUSE=14;

  /*COUNT ALL BITESTNG; NOT INLCUDED AS ONE OF THE CAUSE*/
  IF (CAUSEDT4 GE 9050 AND CAUSEDT4 LE 9056) OR CAUSEDT4=9059 THEN 
BS=1;
  IF (CAUSEDT4 GE 9060 AND CAUSEDT4 LE 9065) OR CAUSEDT4=9069 THEN 
BS=2;
  IF BS=1 OR BS=2 THEN BITESTNG=1;

  /*CAUSE=OVEREXERTION*/
  IF CAUSEDET=927 THEN OVEREXER=1;

  IF OVEREXER=1 THEN CAUSE=15;

  /*CAUSE=OTHER SPEC*/
  IF (CAUSEDET GE 846 AND CAUSEDET LE 848) OR
	  CAUSEDET = 914  OR CAUSEDET = 915  OR CAUSEDET = 918 OR 
	  CAUSEDET = 921  OR  CAUSEDET = 923 OR CAUSEDET = 925 OR 
	  CAUSEDET = 926  OR  (CAUSEDT4 GE 9290 AND CAUSEDT4 LE 9295) OR 
	  CAUSEDT4 = 9555 OR CAUSEDT4 = 9559 OR 
	  CAUSEDT4 = 9580 OR CAUSEDT4 = 9584 OR
	  CAUSEDT4 = 9601 OR (CAUSEDT4 GE 9655 AND CAUSEDT4 LE 9659) OR 
	  CAUSEDET = 967  OR CAUSEDT4 = 9684 OR 
	  CAUSEDET = 971  OR CAUSEDET = 978 OR
	  CAUSEDT4 = 9855 OR
 	  CAUSEDT4 = 9880 OR CAUSEDT4 = 9884 OR 
	 (CAUSEDET GE 990 AND CAUSEDET LE 994) OR CAUSEDET = 996 OR 
	  CAUSEDT4 = 9970 OR CAUSEDT4 = 9971 OR CAUSEDT4 = 9972 OR
	  CAUSEDT4 = 9224 OR CAUSEDT4 = 9225 OR 
      CAUSEDT4 = 9283 OR CAUSEDT4 = 9284 OR CAUSEDT4 = 9285 OR CAUSEDT4 = 9286 OR 
	  CAUSEDT4 = 9556 OR CAUSEDT4 = 9557 OR
      CAUSEDT4 = 9686 OR CAUSEDT4 = 9687 OR
	  CAUSEDT4 = 9856 OR CAUSEDT4 = 9857 OR
	 (CAUSEDET = 979 AND (CAUSEDT4 NOT IN (9793, 9794, 9796, 9797))) 
THEN OTHER=1;

  IF OTHER =1 THEN CAUSE=16;

  /*CAUSE=NEC*/
  IF CAUSEDT4 = 9288 OR CAUSEDT4 = 9298 OR 
	 CAUSEDT4 = 9588 OR CAUSEDET = 959  OR 
	 CAUSEDT4 = 9688 OR CAUSEDET = 969  OR
	 CAUSEDET = 995  OR CAUSEDT4 = 9978 OR 
	 CAUSEDET = 977  OR 
	 CAUSEDET = 998  OR CAUSEDET = 999 OR
	 CAUSEDT4 = 9888 OR CAUSEDET = 989 THEN NEC=1;

  IF NEC=1 THEN CAUSE=17;

  /*CAUSE=NOT SPECIFIED*/
  IF CAUSEDET = 887 OR CAUSEDT4 = 9289 OR CAUSEDT4 = 9299 OR
	 CAUSEDT4 = 9589 OR 
	 CAUSEDT4 = 9689 OR 
	 CAUSEDET = 976 OR CAUSEDT4 = 9979 OR 
	 CAUSEDT4 = 9889  THEN NOTSPEC=1;

  IF NOTSPEC=1 THEN CAUSE=18;

  /*COUNT ALL ADVERSE EFFECTS; NOT INLCUDED AS ONE OF THE CAUSE*/
  IF (CAUSEDET GE 870 AND CAUSEDET LE 879) THEN MEDCARE=1;

  IF (CAUSEDET GE 930 AND CAUSEDET LE 949) THEN DRUGS=1;

  IF MEDCARE=1 OR DRUGS=1 THEN ADVERSE=1;

    /* MANNER-INTENT CODING */
		/*UNINT*/
  IF (CAUSEDET GE 800 AND CAUSEDET LE 869) OR 
	 (CAUSEDET GE 880 AND CAUSEDET LE 929) THEN INJ=1;
	 	/*SUI*/
  IF  CAUSEDET GE 950 AND CAUSEDET LE 959 THEN INJ=2;
  		/*HOM*/
  IF  CAUSEDET GE 960 AND CAUSEDET LE 969 OR 
	  CAUSEDET = 979 OR CAUSEDT4= 9991 THEN INJ=3;
  		/*OTHER*/
  IF (CAUSEDET GE 970 AND CAUSEDET LE 978) OR
	 (CAUSEDT4 GE 9900 AND CAUSEDT4 LE 9990) THEN INJ=4;
	 	/*UNDETERMINED*/
  IF (CAUSEDET GE 980 AND CAUSEDET LE 989) THEN INJ=5;


PROC FORMAT;
VALUE CM 1='MVT'
         11='OTHER PEDAL CYC'
         12='OTHER PEDESTRIAN'
         13='OTHER TRANS'
         2='FIREARM'
         3='POISONING'
         4='FALLS'
         5='SUFFOCATION'
         6='DROWNING'
         7='FIRE/BURN'
         8='CUT/PIERCE'
         9='STRUCK BY/AGAINST'
         10='MACHINERY'
         14='NATURAL/ENVIR'
         15='OVEREXERTION'
         16='OTHER SPEC'
         17='NEC'
         18='NOT SPECIFIED' ;
VALUE MVPM 1='OCCUPANT'
            2='MOTORCYCLIST'
            3='PEDAL CYCLIST'
            4='PEDESTRIAN'
            5='UNKNOWN'
            6='OTHER' ;
VALUE INJM 1='UNINTENTIONAL'
           2='SUICIDE'
           3='HOMICIDE'
           4='OTHER'
           5='UNDETERMINED';

PROC FREQ;
  TABLES   CAUSE*INJ;
  TITLE    INJURY MORTALITY MATRIX;
  FORMAT    INJ INJM. CAUSE CM. ;