BookmarkSubscribeRSS Feed
centro_9
Calcite | Level 5

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 

8 REPLIES 8
PaigeMiller
Diamond | Level 26

What about this code isn't working? Please explain.

--
Paige Miller
centro_9
Calcite | Level 5
no it worked but number looks incorrect 7436258 is the total number in medication file of this claims data and the code above gave me 878 diabetes patients
Reeza
Super User

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.

 

 

 

 

centro_9
Calcite | Level 5
unexpected numbers.. number looks incorrect 7436258 is the total number in medication file of this claims data and the code gave me 878 diabetes patients
Astounding
PROC Star

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;
centro_9
Calcite | Level 5
thank you for your help i USED THIS CODE BUT IT GAVE ME ERROR
"ARRAY SUBSCRIPT OUT OF RANGE AT LINE 333 COUMN 4"
Astounding
PROC Star

To help debug the error, you will have to post the log from running that DATA step.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 8 replies
  • 659 views
  • 2 likes
  • 5 in conversation