Hi,
I'm trying to flag all individuals with diagnosis codes E10, E11, and E13. The problem is, I would like this to include all values for that overarching diagnosis code. So for example, if there are diagnosis codes E11.17, E11.21, E11.34, E10.22, E13.49, I would like to flag any with E10, E11, or E13 to be flagged. My code is below and thanks in advance for any help!
data work.diabetes_control_num;
set work.diabetes_control;
array diag{3} $ diagnosis_1 diagnosis_2 diangosis_3;
array a1c_last{1} a1c2;
do i= 1 to 1;
if a1c_last{i} >= 9 then dm_control=0; else if a1c_last{i}=. then dm_control=.; else dm_control=1;
end;
do i=1 to 3;
if diag{i} = in ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
end;
run;
@RebeccaB_ wrote:
Hi,
I'm trying to flag all individuals with diagnosis codes E10, E11, and E13. The problem is, I would like this to include all values for that overarching diagnosis code. So for example, if there are diagnosis codes E11.17, E11.21, E11.34, E10.22, E13.49, I would like to flag any with E10, E11, or E13 to be flagged. My code is below and thanks in advance for any help!
data work.diabetes_control_num;
set work.diabetes_control;
array diag{3} $ diagnosis_1 diagnosis_2 diangosis_3;
array a1c_last{1} a1c2;
do i= 1 to 1;
if a1c_last{i} >= 9 then dm_control=0; else if a1c_last{i}=. then dm_control=.; else dm_control=1;
end;
do i=1 to 3;
if diag{i} = in ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
end;
run;
Actually almost there. If the values are as you say you could use SCAN or SUBSTR functions to get the first letters from your diag codevalues.
if Scan( diag{i},1,'.') in ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
or
if substr(diag{i},1,3) in ("E10", "E11","E13") then ...
Alternate
Diag_control = ( Scan( diag{i},1,'.') in ("E10", "E11", "E13") );
(Exercise for the interested reader for the similar SUBSTR version).
This assignment works because will assign a 1 for true and 0 for false for any logic comparison.
You don't want to use "= in (<value list>)" just the "in (<value list>)"
@RebeccaB_ wrote:
Hi,
I'm trying to flag all individuals with diagnosis codes E10, E11, and E13. The problem is, I would like this to include all values for that overarching diagnosis code. So for example, if there are diagnosis codes E11.17, E11.21, E11.34, E10.22, E13.49, I would like to flag any with E10, E11, or E13 to be flagged. My code is below and thanks in advance for any help!
data work.diabetes_control_num;
set work.diabetes_control;
array diag{3} $ diagnosis_1 diagnosis_2 diangosis_3;
array a1c_last{1} a1c2;
do i= 1 to 1;
if a1c_last{i} >= 9 then dm_control=0; else if a1c_last{i}=. then dm_control=.; else dm_control=1;
end;
do i=1 to 3;
if diag{i} = in ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
end;
run;
Actually almost there. If the values are as you say you could use SCAN or SUBSTR functions to get the first letters from your diag codevalues.
if Scan( diag{i},1,'.') in ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
or
if substr(diag{i},1,3) in ("E10", "E11","E13") then ...
Alternate
Diag_control = ( Scan( diag{i},1,'.') in ("E10", "E11", "E13") );
(Exercise for the interested reader for the similar SUBSTR version).
This assignment works because will assign a 1 for true and 0 for false for any logic comparison.
You don't want to use "= in (<value list>)" just the "in (<value list>)"
Thank you for the help! I've used both scan and substr but all observations of diag_control are still being flagged as "0", but I can visually see an observation that, for example, has diagnosis_1 = E11.21. Any suggestions in changing my code so that I can capture this?
CODE:
data work.diabetes_control_num;
set work.diabetes_control;
array diag{3} $ diagnosis_1 diagnosis_2 diangosis_3;
array a1c_last{1} a1c2;
do i= 1 to 1;
if a1c_last{i} >= 9 then dm_control=0; else if a1c_last{i}=. then dm_control=.; else dm_control=1;
end;
do i=1 to 3;
if Scan( diag{i},1,'.') in ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
end;
run;
Use the colon operator.
if diag{i} in: ("E10", "E11", "E13") then diag_control=1;
else diag_control=0;
@RebeccaB_ wrote:
Hi,
I'm trying to flag all individuals with diagnosis codes E10, E11, and E13. The problem is, I would like this to include all values for that overarching diagnosis code. So for example, if there are diagnosis codes E11.17, E11.21, E11.34, E10.22, E13.49, I would like to flag any with E10, E11, or E13 to be flagged. My code is below and thanks in advance for any help!
data work.diabetes_control_num;
set work.diabetes_control;
array diag{3} $ diagnosis_1 diagnosis_2 diangosis_3;
array a1c_last{1} a1c2;
do i= 1 to 1;
if a1c_last{i} >= 9 then dm_control=0; else if a1c_last{i}=. then dm_control=.; else dm_control=1;
end;
do i=1 to 3;
if diag{i} = in ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
end;
run;
@Reeza wrote:
Use the colon operator.
if diag{i} in: ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
@RebeccaB_ wrote:
Hi,
I'm trying to flag all individuals with diagnosis codes E10, E11, and E13. The problem is, I would like this to include all values for that overarching diagnosis code. So for example, if there are diagnosis codes E11.17, E11.21, E11.34, E10.22, E13.49, I would like to flag any with E10, E11, or E13 to be flagged. My code is below and thanks in advance for any help!
data work.diabetes_control_num;
set work.diabetes_control;
array diag{3} $ diagnosis_1 diagnosis_2 diangosis_3;
array a1c_last{1} a1c2;
do i= 1 to 1;
if a1c_last{i} >= 9 then dm_control=0; else if a1c_last{i}=. then dm_control=.; else dm_control=1;
end;
do i=1 to 3;
if diag{i} = in ("E10", "E11", "E13") then diag_control=1; else diag_control=0;
end;
run;
Might be an issue if codes of E100, E110 or E130 exist. May not be an issue but there are just so blinking many ICD codes out there ...
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.