BookmarkSubscribeRSS Feed
DMMD
Obsidian | Level 7

Hello,

 

I have a dataset of patients with up to ten different diagnoses (over ten different columns). Each patient, additionally, may have more than one occurrence.

 

How do I program SAS to count the number of patients (unique IDs) with a particular set of diagnoses (i.e. diagnosis 1 or diagnosis 2 or diagnosis 3)? I do not want a frequency count of diagnoses as one patient could return multiple times for the same diagnoses.

 

Thanks!

8 REPLIES 8
Reeza
Super User

Depends a bit. A usual recommendation is to flip your data from wide to long and then do a double proc freq or SQL distinct to get the number of unique people, and use a WHERE clause or filter your diagnosis. 

 

Another option is is to create a flag for the diagnosis and loop through all the diagnoses and set the flag to 1 if the diagnosis is found. 

Then you do a distinct count with a filter on the flag value. 

 

A diagnosis usually isn't a single code, case definitions vary and both methods are equivalent. 

If you need to work with multiple diagnoses the first method is easier to extend. 

DMMD
Obsidian | Level 7

Hi Reeza,

Do you recommend using the methos described in the following link to transform the data?

 

http://www2.sas.com/proceedings/sugi24/Advtutor/p48-24.pdf

 

Thanks!

Reeza
Super User

I prefer proc transpose myself. More dynamic. 

 

Yes, probably in Base SAS, I'll move it. 

DMMD
Obsidian | Level 7
I'll give that a shot. Thank you!
DMMD
Obsidian | Level 7

Hi Reeza,

 

I tried to do proc transpose. My data has over 3 million observations and many columns. There are ten separate columns for diagnoses alone.

 

After running for two hours, I was unable to open the transposed file due to memory issues (not sure what that really means as everything else opens okay).

Reeza
Super User

Then I suggest a datastep to transpose instead. Not all records have 10 diagnoses, many will be empty, correct? 

3 milllion x10 diagnoses - 30 million. Not a small amount but shouldn't cause SAS to crash... 

Reeza
Super User
You've posted this in data mining are you using SAS EM?
DMMD
Obsidian | Level 7

Thanks, Reeza. I will try the first option and keep you updated.

 

I have SAS 9.4 and SAS Enterprise Guide 7.1. Should my post be in a different discussion board?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1451 views
  • 1 like
  • 2 in conversation