from: http://www.stat.colostate.edu/~meyer/sascode.txt libname nass97 '(your directory)\1997\fl1997\'; libname nass98 '(your directory)\1998\fl1998\'; libname nass99 '(your directory)\1999\fl1999\'; libname nass00 '(your directory)\2000\fl2000\'; libname nass01 '(your directory)\2001\'; libname nass02 '(your directory)\2002\'; libname nassall '(your directory)\sascode'; data new97; set nass97.oa; keep bagavail bagfail bagdeply chtype death height weight sex psu caseid caseno vehno occno seatpos injsev age manpropr hospstay yearacc treatmnt role; front=0; if seatpos=11 | seatpos=13 then front=1; if front=0 then delete; if manpropr=.U then delete; if bagavail=.U then delete; if age=.U then delete; if age<16 then delete; if sex=.U then delete; yearacc=1997; run; /* run the above code for each year */ data nassall.oa; set new97 new98 new99 new00 new01 new02; dead=2; if death>0 | injsev=4 then dead=1; if death=.U & injsev=.U then delete; airbag=0; if bagavail=1 then airbag=1; seatbelt=0; if manpropr=1 then seatbelt=1; male=0; if sex=1 then male=1; driver=0; if role=2 then driver=1; run; data gv97; set nass97.gv; yearacc=1997; keep psu caseid vehno bodytype modelyr dvtotal dvbasis dvest dvcat make yearacc; dvcat=0; if dvest=1 | (dvtotal<10 & dvtotal>0) then dvcat=1; else if dvest=2 | (dvtotal<25 & dvtotal>0) then dvcat=2; else if dvest=3 | (dvtotal<40 & dvtotal>0) then dvcat=3; else if dvest=4 | (dvtotal<55 & dvtotal>0) then dvcat=4; else if dvest=5 | dvtotal>54 then dvcat=5; if dvtotal>69 then dvcat=6; if dvcat=0 then delete; run; proc print data=gv91; run; /* run the above code for each year */ data nassall.gv; set gv97 gv98 gv99 gv00 gv01 gv02; car=0; if bodytype<5 or bodytype=7 or bodytype=8 or bodytype=9 or bodytype=40 then car=1; minivan=0; if bodytype=20 then minivan=1; stwagon=0; if bodytype=6 then stwagon=1; suv=0; if bodytype>13 and bodytype<20 then suv=1; pickup=0; if (bodytype>29 and bodytype<40) or bodytype=10 then pickup=1; van=0; if bodytype>20 and bodytype<30 then van=1; if bodytype=11 or bodytype=12 or bodytype=13 or bodytype=41 or bodytype=42 then delete; largecar=0; if van=1 or minivan=1 or pickup=1 or suv=1 then largecar=1; run; data ve02; set nass02.ve; yearacc=2002; keep dof1 gad1 yearacc psu caseid vehno; run; /* run the above code for each year */ data nassall.ve; set ve97 ve98 ve99 ve00 ve01 ve02; run; data acc02; set nass02.accident yearacc=2002; keep yearacc psu psustrat stratif caseid ratwgt ; run; /* run the above code for each year */ data nassall.acc; set acc97 acc98 acc99 acc00 acc01 acc02; run; proc sort data=nassall.gv; by yearacc psu caseid vehno; run; proc sort data=nassall.oa; by yearacc psu caseid vehno; run; proc sort data=nassall.ve; by yearacc psu caseid vehno; run; proc sort data=nassall.acc; by yearacc psu caseid vehno; run; data nassall.oagv; merge nassall.gv nassall.oa; by yearacc psu caseid vehno; if age=. then delete; if dvcat=. then delete; run; proc sort data=nassall.oagv; by yearacc psu caseid vehno; data nassall.oagvve; merge nassall.oagv nassall.ve; by yearacc psu caseid vehno; if dvcat=. then delete; if vehno=. then delete; if gad1='9' or gad1 = 'O' or gad1 = " " then delete; run; proc sort data=nassall.oagvve; by yearacc psu caseid ; data nassall.oagvveacc; merge nassall.oagvve nassall.acc; by yearacc psu caseid; run; /*** important corrections ****/ /* There are three cases with Stratum = E ( no fatality, but at least one occupant of a towed vehicle was transported), but the occupant is listed as killed. For example, look at year=2002, psu=73, case number=135. The "acc_desc" file tells us that this was a low-speed collision at an intersection. An 81 year old man was turning left and hit a car passing throught he intersection. Everyone was OK, but later the man had a heart attack and died. Because the death was not directly caused by the accident, I changed the "death" variable to reflect "not dead" for this case. There are other similar cases where the Stratum seems to be correct, but one of the variables indicates a death. These were checked via the accident description data file, and changed where necessary. There were six such changes. For year=1998, psu=45, psu=152, the driver of the car had a stroke before the accident. The driver was still alive but unconscious after the accident. The car went off the road and into a flower bed, but the cause of the death was the stroke, so I changed the "death" variable to "not dead" because the accident was not severe enough to cause injury. This change was important because the weight value was more than 9700!!! */