BookmarkSubscribeRSS Feed
Marilyn
Calcite | Level 5
Does someone already have some generic code that will pull patients with several ranges of diagnoses from a file that records up to 10 diagnoses at a time?
i.e. I want to pull any patient that had dx 345.00-345.99, or 346.0-346.9, or 296.0-296.9 from multiple years...
6 REPLIES 6
LinusH
Tourmaline | Level 20
I don't have any generic code, but it will help to give some hints if you could show the record lay-out, and some sample data.

/Linus
Data never sleeps
Marilyn
Calcite | Level 5
There's just generic information like name, ssn, diag1 - diag10, DOV, etc...
Doc_Duke
Rhodochrosite | Level 12
No code, but some comments. This looks like Medicare billing data since there is a limit of 10 diagnoses. The size of some of these datasets can be huge, so some approaches (like TRANSPOSE) that are effective for smaller datasets run out of computer resources with larger ones.

ICD codes are character strings, not numbers, so trying to specify a range is tricky (e.g. ICD 345.1 is different from ICD 345.10). If you are just interested in the summary at the first three digits, use the SUBSTR function or the =: operator for the comparison, e.g.
IF diag1 =: '345' | diag1=:'346'...
or
SELECT ...
WHERE substr(diag1,1,3) IN ('345', '346', '296') | ...
Marilyn
Calcite | Level 5
yes...this works quite well.
Now I am working on trying to make an array of the diagnosis codes...
deleted_user
Not applicable
try the following where clause through an sql query:

where
(Diag_Code___Prin between '001' and '00999'
or Diag_Code___Prin between '033' and '03399'
or Diag_Code___Prin in ('V016','V027','V028')

or Diag_Code___Secondary_1 between '001' and '00999'
or Diag_Code___Secondary_1 between '033' and '03399'
or Diag_Code___Secondary_1 in ('V016','V027','V028')

or Diag_Code___Secondary_2 between '001' and '00999'
or Diag_Code___Secondary_2 between '033' and '03399'
or Diag_Code___Secondary_2 in ('V016','V027','V028'))
shellp55
Quartz | Level 8
Hi

Actually I have a similar type format for diagnoses (except it goes to 25) and I create the array of:

array diagcde[25] $ diagcde1-diagcde25;

Then when searching for specific codes I indicate:

do i=1 to 25 until (diagcde = ' ');
if diagcde in substr(diagcde,1,3) in ("C00","C01") then .

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 6 replies
  • 1675 views
  • 0 likes
  • 5 in conversation