Hi I have a group of individuals stored under (ID no) where 1 is the same individual, 2 is a separte individual and so on.
vistno - is the number of times the individual when to clinic
MI - is the condition the patient had
Question:
For each groups of indviduals, I want to generate a new variable 'ch1' whereby if in the MI column there is any presence of a '1' (as MI is binary)
I would like to be coded as 1 only once
SO
If the same patient eg Individual2 went to a clinic twice, and had MI as 1 on each occasion, I only want it to appear once in the column ch1
As you can see I tried:
by IDno: egen ch1 = max(MI)
However, this would code 1 for each time the individual (Idno) went to the clinic, when I only want Stata to just detect if ever the individual had a '1' on any occasion that person went to clinic.
I can't not use the duplicate command - as you can see the numbers within the variables vary.
vistno - is the number of times the individual when to clinic
MI - is the condition the patient had
Question:
For each groups of indviduals, I want to generate a new variable 'ch1' whereby if in the MI column there is any presence of a '1' (as MI is binary)
I would like to be coded as 1 only once
SO
If the same patient eg Individual2 went to a clinic twice, and had MI as 1 on each occasion, I only want it to appear once in the column ch1
As you can see I tried:
by IDno: egen ch1 = max(MI)
However, this would code 1 for each time the individual (Idno) went to the clinic, when I only want Stata to just detect if ever the individual had a '1' on any occasion that person went to clinic.
I can't not use the duplicate command - as you can see the numbers within the variables vary.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(IDno visitno MI ch1) 1 1 0 0 1 2 0 0 2 1 1 1 2 2 1 1 3 1 1 1 3 2 1 1 3 3 1 1 4 1 0 1 4 2 0 1 4 3 1 1 4 4 1 1 end

Comment