BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I need to create a report that will show a count of how many times a patient was seen for the same problem_code, and then find out the providers who saw the most patients with the same problem_codes.

I am able to do a count by Patient_id, but this does not help me. Could you please help???

Patient_id Date Provider Problem_code Problem_description
100 01-Jan-07 Smith 200 Arthritis
100 04-Apr-07 Doe 300 Joint_Pain
100 30-Jun-07 Colby 200 Arthritis
101 14-Feb-07 Doe 210 Back_Pain
101 07-Sep-07 Doe 210 Back_Pain
102 16-Jun-07 Mark 214 Headache
102 24-Jun-07 Smith 200 Arthritis
....
2 REPLIES 2
Olivier
Pyrite | Level 9
Hi Nathalie.
By the way, I don't think you're posting in the right forum. That would rather be a question for the SAS PROCEDURES category.
Anyway, you can easily solve your problem with a little bit of SQL, which allows you to count, group, order, compute new variables all a the same time.
[pre]
DATA test ;
INPUT Patient_id $ Date anydtdte. Provider $ Problem_code $ Problem_description :$20. ;
FORMAT date DDMMYY10. ;
CARDS ;
100 01-Jan-07 Smith 200 Arthritis
100 04-Apr-07 Doe 300 Joint_Pain
100 30-Jun-07 Colby 200 Arthritis
101 14-Feb-07 Doe 210 Back_Pain
101 07-Sep-07 Doe 210 Back_Pain
102 16-Jun-07 Mark 214 Headache
102 24-Jun-07 Smith 200 Arthritis
;
RUN ;
PROC SQL ;
SELECT patient_id, problem_code, problem_description, count(*) AS number LABEL="# of times"
FROM test
GROUP BY patient_id, problem_code, problem_description
ORDER BY number DESC
;
SELECT provider,
COUNT(*) AS totn LABEL="Total # of visits",
COUNT(DISTINCT patient_id!!problem_code) AS problemsN LABEL="The # of distinct problems on distinct patients",
CALCULATED totn - CALCULATED problemsN AS reRuns LABEL="The # of visits for already seen combination of patients and problems"
FROM test
GROUP BY provider
ORDER BY reRuns DESC
;
QUIT ;
[/pre]
Regards.
Olivier
deleted_user
Not applicable
Thank you for your response. Very much appreciated 🙂

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 725 views
  • 0 likes
  • 2 in conversation