/************************************************************************/ /* */ /* Title: trauma_estimate.do */ /* Author: S. Goble, Statitician NTDB */ /* Project: National Sample Project (NSP) */ /* */ /* Purpose: Create statistical estimates for head injuries */ /* by analyzing the weighted data taking into account */ /* the sample design. */ /* */ /* Input data: 1. The final weights and Strata indicators */ /* for each incident */ /* Name: Weights */ /* Variables needed: Name: */ /* Incident ID INC_KEY */ /* Facility ID FAC_KEY */ /* Strata STRATA */ /* Weights WEIGHTS */ /* */ /* 2. Information pertaining to a diagnosis */ /* made about the trauma incident. */ /* Name: Diagnosis */ /* Variables needed: Name: */ /* Incident ID INC_KEY */ /* Diagnosis code DCODE */ /* */ /* 3. Includes information about the patient */ /* and incident demographics. */ /* Name: Demo */ /* Variables needed: Name: */ /* Incident ID INC_KEY */ /* Age AGE */ /* Gender GENDER */ /* Race RACE */ /* */ /* 4. Includes information pertaining to the outcome */ /* of the trauma incident. */ /* Name: Outcome */ /* Variables needed: Name: */ /* Incident ID INC_KEY */ /* Discharge status DISSTATUS */ /* Hospital lengt of stay LOS */ /* ICU length of stay ICU day */ /* */ /* Output: Frequency estimate of gender, race and discharge status */ /* Mean estimate of Age, LOS and ICU days */ /* */ /* Created: April, 2007 */ /* */ /* **There are 8 weighting strata that are combinations of */ /* 4 Census regions and 2 designated levels of trauma care */ /* level I or level II. (non-ntdb data not available for 2003 data) */ /************************************************************************/ clear set memory 700000 * Change the following: 'D:\data\NSP\Files_sent_out\Data_Sets' to '\yourpathname\'; /*folder for saving input and output Data_Sets*/ * WEIGHTS insheet using D:\data\NSP\Files_sent_out\Data_Sets\Weights.csv save D:\data\NSP\Temp\Weights.dta, replace clear * VALID TRAUMA RECORDS EXCLUDING HIP FRACTURES insheet using D:\data\NSP\Files_sent_out\Data_Sets\Diagnos.csv * KEEP VALID TRAUMA D-CODE drop if dcode<800 drop if dcode>=960 drop if dcode>=905 & dcode<910 drop if dcode>=910 & dcode<925 drop if dcode>=930 & dcode<940 * EXCLUDE HIP-FRACTURES drop if dcode>=820 & dcode<821 sort inc_key * KEEP ONE RECORD PER INCIDENT by inc_key: gen idkey=1 if _n==1 keep if idkey==1 save D:\data\NSP\Temp\Diagnos.dta, replace clear * DEMOGRAPHICS insheet using D:\data\NSP\Files_sent_out\Data_Sets\Demo.csv sort inc_key save D:\data\NSP\Temp\Demo.dta, replace clear * OUTCOME insheet using D:\data\NSP\Files_sent_out\Data_Sets\Outcome.csv sort inc_key save D:\data\NSP\Temp\Outcome.dta, replace clear *MERGE FILES use D:\data\NSP\Temp\Weights.dta sort inc_key ** KEEP ONLY RECORDS WITH WEIGHT AND VALID TRAUMA CODE merge inc_key using D:\data\NSP\Temp\Diagnos.dta keep if _merge==3 drop _merge sort inc_key merge inc_key using D:\data\NSP\Temp\Demo.dta keep if _merge==3 drop _merge sort inc_key merge inc_key using D:\data\NSP\Temp\Outcome.dta keep if _merge==3 drop _merge * REFORMAT FILES FOR PROPORTIONAL ESTIMATES gen dead=0 replace dead=1 if disstatus=="Dead" replace dead=. if disstatus=="" gen racecat=0 replace racecat=1 if race=="White, not of Hispanic Origin" replace racecat=2 if race=="Black" replace racecat=3 if race=="Asian or Pacific Islander" replace racecat=4 if race=="Hispanic" replace racecat=5 if race=="Native American or Alaskan Nati" replace racecat=6 if race=="Other" replace racecat=. if race=="" gen male=0 replace male=1 if gender=="Male" replace male=. if gender=="" drop dcodedescr save D:\data\NSP\Temp\analyze.dta, replace * STATISTICAL ANALYSES svyset fac_key [pweight=weights], strata(strata) *ESTIMATING MEAN OF AGE LOS AND ICUDAYS svy: mean age svyset fac_key [pweight=weights], strata(strata) svy: mean los svyset fac_key [pweight=weights], strata(strata) svy: mean icudays svyset fac_key [pweight=weights], strata(strata) svy: prop dead svyset fac_key [pweight=weights], strata(strata) svy: prop male svyset fac_key [pweight=weights], strata(strata) svy: prop racecat