@ballardw Thank you. Your coding is very helpful. Now I would like to identify "Pre" and "Post first stroke" for AFIB and ONLY "Post Stroke" for Seizure. I will put my code in </> moving forward. You say " the initial/first ever cancer diagnosis (Ischemic Stroke or Hemorrhagic Stroke)", which is it Cancer or stroke? You don't provide any actual details to identify cancer and I know from family history that Ischemic Stroke is not cancer. Answer:I mean initial stroke NOT cancer. Your repeatedly say "create a label". Does this mean a variable with the name Label? (which has issues around records that would need multiple 'label's) Or create a variable named "Recurrent", for example with some value? Which means we need to know the value you want. Answer: I want to create a variable named "Recurrent", with 1 or 0. You seem to have some of the ICD 9 and 10 codes listed of interest (example AFIB and Seizure) but don't have ICD 10 for the others. So are the lists actually complete? Answer: There are multiple icd codes per record but I am only interested in AFIB & seizure. For example 1 patient may have dx of AFIB, stroke , eye infection but am only interested in the AFIB and stroke. You also have the same ICD codes in multiple descriptions Ischemic Stroke, Hemorrhagic Stroke and Recurrent Ischemic Stroke. Are we supposed to have some additional rules as to which is which or is this just a not very clear description of some use of the ICD code. Answer: Same code should be use as initial and recurrent Ischemic Stroke or Hemorrhagic Stroke, the rule that applies is first icd will be the "initial" and other repeated code will be "recurrent". So can you provide an example of what you expect the output to look like for at least one ID with AFIB and one with seizure? Answer: I would like to have variables "Pre" and "Post" initial stroke depending on the encounter date and initial stroke date. Id diagnosis_dt _label_ Icd1 icd_text First_IS First_HS First_AFIB Recurrent AFIB Pre- first stroke Post-first stroke 0987234 08MAY2003 dx1 42731 AFIB 1 1 0987234 30JUL2006 dx1 4321 Hemorr Stroke . 1 . . 0987234 14AUG2006 dx2 42731 AFIB . . . 1 . 1
... View more