Hi everyone I wanted to get type 2 diabetes patients from claims data?
DATA Array2;
SET MED;
ARRAY cc (10) $ MEDICAL_PRIMARY_DIAGNOSIS_CODE
MEDICAL_DIAGNOSIS_CODE_2-MEDICAL_DIAGNOSIS_CODE_9;
DIABETESc=0;
DO i=1 TO 10;
IF cc (i) in ('250') then
DIABETESc=1;
IF cc (i) in ('E11.9' 'E11.8' 'E11.9' 'E11.69' 'E11.51' 'E11.21' 'E11.620'
'E11.621' 'E11.00-E11.65') then
DIABETESc=1;
END;
If DIABETESc=. then
DIABETESc=0;
RUN;
PROC SORT DATA=array2;
BY Patient_ID DESCENDING DIABETESc;
RUN;
DATA ARRAY3;
SET array2;
BY Patient_ID;
IF FIRST.Patient_ID;
RUN;
/*REMOVE THE MISSING VALUE FROM THE DATA*/
DATA ARRAY4;
SET ARRAY3;
IF DIABETESc=. THEN
DELETE;
RUN;
/*COUNT ONLY diabetes PATIENTS*/
DATA ARRAY5;
SET ARRAY4;
IF DIABETESc=1;
RUN;
/*NUMBERS OF DIABETES PATIENTS*/
PROC FREQ DATA=ARRAY5;
TABLES DIABETESc;
RUN;The problem is it gave me unexpected number of diabetes patients
What about this code isn't working? Please explain.
I cleaned up your post a bit, formatted your code and put it in a code block.
What is the issue with the code? Are you getting unexpected results or errors?
There are a few ways to simplify this code for sure but without understanding your issue hard to know where to start.
The likely culprit is here:
IF cc (i) in ('E11.9' 'E11.8' 'E11.9' 'E11.69' 'E11.51' 'E11.21' 'E11.620'
'E11.621' 'E11.00-E11.65') then
DIABETESc=1;
This does not define a range of values:
'E11.00-E11.65'
Rather, it defines a single value that is 13 characters long. If there are no other values that would be selected by the comparison below, you could use it:
IF cc (i) in ('E11.9' 'E11.8' 'E11.9' 'E11.69' 'E11.51' 'E11.21' 'E11.620'
'E11.621') or ('E11.00' <= cc(i) <= 'E11.65') then
DIABETESc=1;
To help debug the error, you will have to post the log from running that DATA step.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.