I have the following problem: I want to identify certain diagnoses based on ICD-10 medical codes listed below. The list is not exhaustive. For example, the array depression_codes contains medical codes for a diagnosis of depression. I want to construct the variable medpar_depression and set it to 1 if there is a diagnosis of depression, 0 if there is a diagnosis of another condition (such as nonalzheimers_codes ), and -1 if there are medical codes that I do not have access to. The variables DGNS_1_CD through DGNS_25_CD might contain ICD-10 codes that are unknown to me and should be marked as -1 if they don’t match any known codes. To solve this problem, I used the loop and array below. Is it allowed to use the in operator in this manner, to check if one array has elements inside another array? thank you for any advice on this question. do i = 1 to 25; if (DGNS[i]) in depression_codes then MEDPAR_DEPRESSION =1; end; run; proc freq data = medicare.merged_medpar_mbsf_pdpn_2019_2; table MEDPAR_DEPRESSION/list missing; run; data medicare.merged_medpar_mbsf_pdpn_2019_2; set medicare.merged_medpar_mbsf_pdpn_2019_2; array DGNS $25 DGNS_1_CD -- DGNS_25_CD; DEPRESSION_MEDPAR = 0; NONALZH_DEMEN_MEDPAR = 0; ALZH_MEDPAR = 0; PNEUMO_MEDPAR = 0; hf_medpar = 0; PRKNSN_MEDPAR = 0; STROKE_TIA_MEDPAR =.; ANXI_MEDICARE_MEDPAR =0; BIPOLAR_MEPAR = 0; TBI_MEDPAR = 0; DRUGS_MEDPAR = 0; SCHIOT_MEDPAR = 0; OUD_ANY_MEDPAR = 0; array depression_codes[50] $8 _temporary_ ('F0631', 'F0632', 'F310', 'F3110', 'F3111', 'F3112', 'F3113', 'F312', 'F3130', 'F3131', 'F3132', 'F314', 'F315', 'F3160', 'F3161', 'F3162', 'F3163', 'F3164', 'F3171', 'F3173', 'F3175', 'F3176', 'F3177', 'F3178', 'F3181', 'F3189', 'F319', 'F320', 'F321', 'F322', 'F323', 'F324', 'F325', 'F328', 'F3289', 'F329', 'F32A', 'F330', 'F331', 'F332', 'F333', 'F3340', 'F3341', 'F3342', 'F338', 'F339', 'F340', 'F341', 'F4321', 'F4323'); array nonalzhimers_codes[84] $8 _temporary_ ('F0150', 'F0151', 'F01511', 'F01518', 'F0152', 'F0153', 'F0154', 'F01A0', 'F01A11', 'F01A18', 'F01A2', 'F01A3', 'F01A4', 'F01B0', 'F01B11', 'F01B18', 'F01B2', 'F01B3', 'F01B4', 'F01C0', 'F01C11', 'F01C18', 'F01C2', 'F01C3', 'F01C4', 'F0280', 'F0281', 'F02811', 'F02818', 'F0282', 'F0283', 'F0284', 'F02A0', 'F02A11', 'F02A18', 'F02A2', 'F02A3', 'F02A4', 'F02B0', 'F02B11', 'F02B18', 'F02B2', 'F02B3', 'F02B4', 'F02C0', 'F02C11', 'F02C18', 'F02C2', 'F02C3', 'F02C4', 'F0390', 'F0391', 'F03911', 'F03918', 'F0392', 'F0393', 'F0394', 'F03A0', 'F03A11', 'F03A18', 'F03A2', 'F03A3', 'F03A4', 'F03B0', 'F03B11', 'F03B18', 'F03B2', 'F03B3', 'F03B4', 'F03C0', 'F03C11', 'F03C18', 'F03C2', 'F03C3', 'F03C4', 'F05', 'G138', 'G3101', 'G3109', 'G311', 'G312', 'G3183', 'G94', 'R4181');
... View more