我想在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*")但是,是否有一种在给定范围内执行字符串匹配的方法?
发布于 2022-05-12 19:49:48
根据我对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")https://stackoverflow.com/questions/72220773
复制相似问题