***ICD Code Extraction. *This syntax (mostly) automates the writing of a long syntax program based on information from an Excel file (code and label). *Version: 10-27-08. *Improvements, suggestions, etc. to David.Laflamme@unh.edu. *Import the Excel file first -- you need two columns (variables). *Vars="code" and "label". *Strip decimals. compute code=replace(code,".", ""). exe. *Create syntax to count each ICD9 code in principle diagnosis field and 9 secondary diagnosis fields. string syntax (a500). compute syntax=concat("count var",rtrim(code),"=principal_diagnosis_cde secondary_diag1_cde", " secondary_diag2_cde secondary_diag3_cde secondary_diag4_cde secondary_diag5_cde", " secondary_diag6_cde secondary_diag7_cde secondary_diag8_cde secondary_diag9_cde ('",rtrim(code),"')."). exe. *Create variable label syntax. string labels (a500). compute labels=concat("variable labels var",rtrim(code)," '",rtrim(code),":",rtrim(label),"'."). *Output variable names for other programming (i.e. make available a list for cutting and pasting). string varnames (a500). compute varnames=concat("var",rtrim(code)). exe. *Output variable names with plus sign for other programming (i.e. make available a list for cutting and pasting). string varnames2 (a500). compute varnames2=concat("var",rtrim(code)," +"). exe. *Manually cut and paste the string values of the new variables, starting with the new variable called "syntax", into a syntax file. *Run the new program on the hospital discharge dataset.