Hello, I am trying to figure out how to create a column that tells me whether or not a specific visit date is the visit of interest. For example in the data examples below, I show part of what the data looks like and then what I want. I have a column that gives the date of the visit of interest (presample_date) and also a place where all visits are listed (all_visits). I want to be able to have a row which says whether the visit date is the visit of interest for each specific patient. In this specific instance there is not 1 visit of interest for each record as shown, but if there is any code that could also eventually be applicable if there was more than one date that would be helpful!
Example:
input str16 record_id float (all_visits presample_date precollection_yes_no)
"Sub1" 20870 21457 .
"Sub1" 21457 21457 .
"Sub1" 21222 21457 .
"Sub1" 21345 21457 .
"Sub2" 20320 20320 .
"Sub2" 21555 20320 .
"Sub3" 20345 21123 .
"Sub3" 21333 21123 .
"Sub3" 21567 21123 .
"Sub3" 21222 21123 .
"Sub3" 21145 21123 .
"Sub3" 21123 21123 .
end
Example of what I want:
input str16 record_id float (all_visits presample_date precollection_yes_no)
"Sub1" 20870 21457 0
"Sub1" 21457 21457 1
"Sub1" 21222 21457 0
"Sub1" 21345 21457 0
"Sub2" 20320 20320 1
"Sub2" 21555 20320 0
"Sub3" 20345 21123 0
"Sub3" 21333 21123 0
"Sub3" 21567 21123 0
"Sub3" 21222 21123 0
"Sub3" 21145 21123 0
"Sub3" 21123 21123 1
end
*Where '1' is yes and '0' is no
Also just to note my data the date information is actually int I just could not figure out how to get it to run for my examples, but if this changes anything about how the code should be written it would be helpful to know!
Thank you for the help!
Example:
input str16 record_id float (all_visits presample_date precollection_yes_no)
"Sub1" 20870 21457 .
"Sub1" 21457 21457 .
"Sub1" 21222 21457 .
"Sub1" 21345 21457 .
"Sub2" 20320 20320 .
"Sub2" 21555 20320 .
"Sub3" 20345 21123 .
"Sub3" 21333 21123 .
"Sub3" 21567 21123 .
"Sub3" 21222 21123 .
"Sub3" 21145 21123 .
"Sub3" 21123 21123 .
end
Example of what I want:
input str16 record_id float (all_visits presample_date precollection_yes_no)
"Sub1" 20870 21457 0
"Sub1" 21457 21457 1
"Sub1" 21222 21457 0
"Sub1" 21345 21457 0
"Sub2" 20320 20320 1
"Sub2" 21555 20320 0
"Sub3" 20345 21123 0
"Sub3" 21333 21123 0
"Sub3" 21567 21123 0
"Sub3" 21222 21123 0
"Sub3" 21145 21123 0
"Sub3" 21123 21123 1
end
*Where '1' is yes and '0' is no
Also just to note my data the date information is actually int I just could not figure out how to get it to run for my examples, but if this changes anything about how the code should be written it would be helpful to know!
Thank you for the help!