I would like to know how to generate a variable which contains in numeric sequence, the number of repeated observations for each record_id, for example:
If there are 3 surveys completed by a patient and each survey is one observation in a stata dataset, how do I create and add values (sequence of when completed) to a variable for each observation per patient? So PatientA fills out the same survey on 1st Jan, 2nd March and 20th July. How to I have a 'repeat_instance' variable that will have the value '1' for that patient's survey on 1st Jan, a '2' for the survey completed 2nd March, and a '3' for the survey completed 20th July? I would then want the numbering to start again from '1' for PatientB and so on.
If there are 3 surveys completed by a patient and each survey is one observation in a stata dataset, how do I create and add values (sequence of when completed) to a variable for each observation per patient? So PatientA fills out the same survey on 1st Jan, 2nd March and 20th July. How to I have a 'repeat_instance' variable that will have the value '1' for that patient's survey on 1st Jan, a '2' for the survey completed 2nd March, and a '3' for the survey completed 20th July? I would then want the numbering to start again from '1' for PatientB and so on.
Comment