字符串搜索 ICD 代码范围
String search for range of ICD codes
我想在 Stata 中搜索 C00-D49 并将它们标记为肿瘤。
我可以
gen neo =1 if strmatch(diagnosis, "C*")
但是,不确定如何将字符串搜索限制在 D49 以内。
此外,我需要将 O00-O9A 标记为怀孕。
我也可以做以下事情:
gen neo =1 if strmatch(diagnosis, "D1*")
gen neo =1 if strmatch(diagnosis, "D2*")
gen neo =1 if strmatch(diagnosis, "D3*")
gen neo =1 if strmatch(diagnosis, "D4*")
但是,有没有办法对给定范围执行字符串匹配?
我理解的 ICD 代码组织方式,它们都是按字母顺序排列的。所以你不需要搜索任何字符串,只需按字母顺序比较它们:
* Example generated by -dataex-. For more info, type help dataex
clear
input str7 diagnosis
"ABB"
"A12"
"C34"
"D49.512"
"O02"
"Q34"
"C00.2"
end
gen neoplasm = (diagnosis >= "C00" & diagnosis < "D50")
gen pregnancy = (diagnosis >= "O00" & diagnosis < "P")
我想在 Stata 中搜索 C00-D49 并将它们标记为肿瘤。
我可以
gen neo =1 if strmatch(diagnosis, "C*")
但是,不确定如何将字符串搜索限制在 D49 以内。
此外,我需要将 O00-O9A 标记为怀孕。
我也可以做以下事情:
gen neo =1 if strmatch(diagnosis, "D1*")
gen neo =1 if strmatch(diagnosis, "D2*")
gen neo =1 if strmatch(diagnosis, "D3*")
gen neo =1 if strmatch(diagnosis, "D4*")
但是,有没有办法对给定范围执行字符串匹配?
我理解的 ICD 代码组织方式,它们都是按字母顺序排列的。所以你不需要搜索任何字符串,只需按字母顺序比较它们:
* Example generated by -dataex-. For more info, type help dataex
clear
input str7 diagnosis
"ABB"
"A12"
"C34"
"D49.512"
"O02"
"Q34"
"C00.2"
end
gen neoplasm = (diagnosis >= "C00" & diagnosis < "D50")
gen pregnancy = (diagnosis >= "O00" & diagnosis < "P")