/************************************************************************** | | STATA SETUP FILE FOR ICPSR 04431 | TREATMENT EPISODE DATA SET (TEDS), 2004 | | | Please edit this file as instructed below. | To execute, start Stata, change to the directory containing: | - this do file | - the ASCII data file | - the dictionary file | | Then execute the do file (e.g., do 04431-0001-statasetup.do) | **************************************************************************/ set mem 300m /* Allocating 300 megabyte(s) of RAM for Stata SE to read the data file into memory. */ set more off /* This prevents the Stata output viewer from pausing the process*/ /**************************************************** Section 1: File Specifications This section assigns local macros to the necessary files. Please edit: "data-filename" ==> The name of data file downloaded from ICPSR "dictionary-filename" ==> The name of the dictionary file downloaded. "stata-datafile" ==> The name you wish to call your Stata data file. Note: We assume that the raw data, dictionary, and setup (this do file) all reside in the same directory (or folder). If that is not the case you will need to include paths as well as filenames in the macros. ********************************************************/ local raw_data "data-filename" local dict "dictionary-filename" local outfile "stata-datafile" /******************************************************** Section 2: Infile Command This section reads the raw data into Stata format. If Section 1 was defined properly, there should be no reason to modify this section. These macros should inflate automatically. **********************************************************/ infile using `dict', using (`raw_data') clear /********************************************************* Section 3: Value Label Definitions This section defines labels for the individual values of each variable. We suggest that users do not modify this section. **********************************************************/ label data "Treatment Episode Data Set (TEDS), 2004, Dataset 0001" #delimit ; label define YEAR -9 "MISSING/UNKNOWN/NOT COLLECTED/INVALID" ; label define STATE -9 "MISSING/UNKNOWN/NOT COLLECTED/INVALID" 1 "ALASKA" 2 "ALABAMA" 3 "ARKANSAS" 4 "ARIZONA" 5 "CALIFORNIA" 6 "COLORADO" 7 "CONNECTICUT" 8 "DIST OF COLUMBIA" 9 "DELAWARE" 10 "FLORIDA" 11 "GEORGIA" 12 "HAWAII" 13 "IOWA" 14 "IDAHO" 15 "ILLINOIS" 16 "INDIANA" 17 "KANSAS" 18 "KENTUCKY" 19 "LOUISIANA" 20 "MASSACHUSETTS" 21 "MARYLAND" 22 "MAINE" 23 "MICHIGAN" 24 "MINNESOTA" 25 "MISSOURI" 26 "MISSISSIPPI" 27 "MONTANA" 28 "NORTH CAROLINA" 29 "NORTH DAKOTA" 30 "NEBRASKA" 31 "NEW HAMPSHIRE" 32 "NEW JERSEY" 33 "NEW MEXICO" 34 "NEVADA" 35 "NEW YORK" 36 "OHIO" 37 "OKLAHOMA" 38 "OREGON" 39 "PENNSYLVANIA" 40 "PUERTO RICO" 41 "RHODE ISLAND" 42 "SOUTH CAROLINA" 43 "SOUTH DAKOTA" 44 "TENNESSEE" 45 "TEXAS" 46 "UTAH" 47 "VIRGINIA" 48 "VERMONT" 49 "WASHINGTON" 50 "WISCONSIN" 51 "WEST VIRGINIA" 52 "WYOMING" ; . . . . label define FRSTUSE3 -9 "MISSING/UNKNOWN/NOT COLLECTED/INVALID" 1 "11 AND UNDER" 2 "12-14" 3 "15-17" 4 "18-20" 5 "21-24" 6 "25-29" 7 "30-34" 8 "35-39" 9 "40-44" 10 "45-49" 11 "50-54" 12 "55 AND OVER" ; label define IDU -9 "DRUGS USED; NO ROUTES REPORTED" -8 "NO SUBSTANCES REPORTED" 0 "NO IDU REPORTED" 1 "IDU REPORTED" ; label define ALCFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define COKEFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define MARFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define HERFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define METHFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define OPSYNFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define PCPFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define HALLFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define MTHAMFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define AMPHFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define STIMFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define BENZFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define TRNQFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define BARBFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define SEDHPFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define INHFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define OTCFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define OTHERFLG 0 "SUBSTANCE NOT REPORTED" 1 "SUBSTANCE REPORTED" ; label define ALCDRUG 0 "NONE" 1 "ALCOHOL ONLY" 2 "OTHER DRUGS ONLY" 3 "ALCOHOL AND OTHER DRUGS" ; #delimit cr /*************************************************************************** Section 4: Missing Values This section will replace numeric missing values (i.e., -9) with generic system missing ".". By default the code in this section is commented out. Users wishing to apply the generic missing values should remove the comment at the beginning and end of this section. Note that Stata allows you to specify up to 27 unique missing value codes. ****************************************************************/ /* replace YEAR = . if (YEAR == -9) replace STATE = . if (STATE == -9) replace PMSA = . if (PMSA == -9) replace CBSA = . if (CBSA == -9) replace REGION = . if (REGION == -9) replace DIVISION = . if (DIVISION == -9) replace SERVSET = . if (SERVSET == -9) replace NOPRIOR = . if (NOPRIOR == -9) replace PSOURCE = . if (PSOURCE == -9) replace GENDER = . if (GENDER == -9) replace AGE = . if (AGE == -9) replace RACE = . if (RACE == -9) replace ETHNIC = . if (ETHNIC == -9) replace EDUC = . if (EDUC == -9) replace EMPLOY = . if (EMPLOY == -9) replace METHUSE = . if (METHUSE == -9) replace PSYPROB = . if (PSYPROB == -9) replace DSMCRIT = . if (DSMCRIT == -9) replace PREG = . if (PREG == -9) replace VET = . if (VET == -9) replace LIVARAG = . if (LIVARAG == -9) replace PRIMINC = . if (PRIMINC == -9) replace HLTHINS = . if (HLTHINS == -9) replace PRIMPAY = . if (PRIMPAY == -9) replace DETNLF = . if (DETNLF == -9) replace DETCRIM = . if (DETCRIM == -9) replace MARSTAT = . if (MARSTAT == -9) replace DAYWAIT = . if (DAYWAIT == -9) replace SUB1 = . if (SUB1 == -9) replace ROUTE1 = . if (ROUTE1 == -9) replace FREQ1 = . if (FREQ1 == -9) replace FRSTUSE1 = . if (FRSTUSE1 == -9) replace SUB2 = . if (SUB2 == -9) replace ROUTE2 = . if (ROUTE2 == -9) replace FREQ2 = . if (FREQ2 == -9) replace FRSTUSE2 = . if (FRSTUSE2 == -9) replace SUB3 = . if (SUB3 == -9) replace ROUTE3 = . if (ROUTE3 == -9) replace FREQ3 = . if (FREQ3 == -9) replace FRSTUSE3 = . if (FRSTUSE3 == -9) replace IDU = . if (IDU <= -8 ) replace ALCDRUG = . if (ALCDRUG <= -9 ) */ /******************************************************************** Section 5: Save Outfile This section saves out a Stata system format file. There is no reason to modify it if the macros in Section 1 were specified correctly. *********************************************************************/ save `outfile', replace