Hi all,
I am using STATA 15.1 and I have a new problem and it is a challenge, at least for me if I want to solve it in most efficient way. After searching the forum for answers its seems that has not been illustrated in details and examples. So, let me ask these please:
1) How to check if the string varlist var1-var16 has period e.g C45.1 - D25.9 etc.?
2) How to remove that period and keep the digits that followed it. e.g It should be C451 and D259? Preferably without destring.
3) Now regarding the data; I have ICD10 variables for diseases s_40006_0_0 to s_40006_16_0 BUT s_40006_12_0 and s_40006_14_0 are not there. Also, I have diagnosis age variables n_40008_0_0 up to n_40008_31_0 "Sequentially completed".
Here what I have tried:
It worked but if I want to add other diseases codes along with C61 it returns zero obs which is not true.
The second inquiry is I tried the codes I have for numeric variables, thanks to Clyde Schechter which is to pair the lowest age value with corresponding diagnosis code using " " but it doesn't work here. Also, I wonder if it is possible to do paring where there are two missing part in s_40006 as mentioned above?
The code I used for coding age is:
The sample data as follows:
Any suggestions would be highly appreciated.
I am using STATA 15.1 and I have a new problem and it is a challenge, at least for me if I want to solve it in most efficient way. After searching the forum for answers its seems that has not been illustrated in details and examples. So, let me ask these please:
1) How to check if the string varlist var1-var16 has period e.g C45.1 - D25.9 etc.?
2) How to remove that period and keep the digits that followed it. e.g It should be C451 and D259? Preferably without destring.
3) Now regarding the data; I have ICD10 variables for diseases s_40006_0_0 to s_40006_16_0 BUT s_40006_12_0 and s_40006_14_0 are not there. Also, I have diagnosis age variables n_40008_0_0 up to n_40008_31_0 "Sequentially completed".
Here what I have tried:
Code:
//// Cases //// generate hasC61= 0 foreach var of varlist s_40006_0_0- s_40006_16_0{ replace hasC61= 1 if strpos(`var',"C61") } tab hasC61
Code:
//// Cases //// generate cases= 0 foreach var of varlist s_40006_0_0 - s_40006_16_0 { replace cases= 1 if strpos(`var',"C61 D400") } tab cases
The code I used for coding age is:
Code:
ds n_40006* local n40006s `r(varlist)' gen Age = . foreach v of varlist `n40006s' { local pairing: subinstr local v "40006" "40008" confirm numeric var `pairing' replace Age = `pairing' if `v' == "C61" & `pairing' < Age
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str5(s_40006_0_0 s_40006_1_0 s_40006_2_0 s_40006_3_0 s_40006_4_0 s_40006_5_0) double(n_40008_0_0 n_40008_1_0 n_40008_2_0 n_40008_3_0 n_40008_4_0 n_40008_5_0) "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "C509" "" "" "" "" "" 56.4 56.4064 . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "C504" "" "" "" "" "" 68.5 68.5024 68.5024 . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "C187" "" "" "" "" "" 57.8 57.7507 57.7507 . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "C64" "" "" "" "" "" 56.5 56.5022 56.5022 . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "" "" "" "" "" "" . . . . . . "C187" "C508" "" "" "" "" 37.20000000000001 54.4 54.4323 37.2027 54.4323 . "" "" "" "" "" "" . . . . . . end
Any suggestions would be highly appreciated.
Comment