Dear all,
I'd like to extract a part of a string from a string variable, to be specific: the indication in a radiology report.
I created the following loop to extract a part of text starting with "indication"/"indications"/"history" AND ending with "view"/"views"
However, it looks for the last time "view"/"views" is used in the report, while it should pick up the string between "indication"/"indications"/"history" AND the first time "view"/"views" is used.
foreach x in indication indications history{
foreach y in view views {
replace indication = regexs(2) if regexm(lower(report_text),"(`x': )(.*)(`y')") & indication == ""
}
}
Thank you,
Stein
I'd like to extract a part of a string from a string variable, to be specific: the indication in a radiology report.
I created the following loop to extract a part of text starting with "indication"/"indications"/"history" AND ending with "view"/"views"
However, it looks for the last time "view"/"views" is used in the report, while it should pick up the string between "indication"/"indications"/"history" AND the first time "view"/"views" is used.
foreach x in indication indications history{
foreach y in view views {
replace indication = regexs(2) if regexm(lower(report_text),"(`x': )(.*)(`y')") & indication == ""
}
}
Thank you,
Stein
Comment