BookmarkSubscribeRSS Feed
Asquared
Calcite | Level 5

I am trying to obtain different treatment regimens from my data for firstline treatment (i.e treatment received only during the first visit) and, also, the frequency(count) by which these different treatment regimens occur grouped by diagnosis in order to finalize one treatment regimen for each diagnosis.  (Note- firstline treatment regimen can be a single drug/combination of drugs depending upon the patient).
Also,  what would be an efficient way to graphically represent the duration of the overall treatment regimens given that each date contains either one or more than one observations per patient_ID.The dataset looks like this:

 

 

data have;
input id diagnosis $ trt_date mmddyy10. drug_code $;
format trt_date mmddyy10.;
datalines;
50 CAD 1/24/2010 A
50 CAD 1/24/2010 B
50 CAD 1/27/2010 A
50 CAD 1/27/2010 B
50 CAD 1/30/2010 A
50 CAD 1/30/2010 B
65 CAD 1/23/2010 B
65 CAD 1/24/2010 A
65 CAD 1/26/2010 A
65 CAD 1/28/2010 A
78 CHD 2/21/2010 A
78 CHD 2/21/2010 A
78 CHD 2/25/2010 A
78 CHD 2/25/2010 B
78 CHD 3/1/2010 A
78 CHD 3/1/2010 B
80 CAD 1/21/2010 B
80 CAD 1/31/2010 B
80 CAD 2/10/2010 B
85 CHD 6/19/2010 A
85 CHD 6/19/2010 B
85 CHD 6/25/2010 A
85 CHD 6/25/2010 B
85 CHD 7/1/2010 A
85 CHD 7/1/2010 B
89 CHD 12/19/2010 A
89 CHD 12/19/2010 B
89 CHD 12/22/2010 A
89 CHD 12/22/2010 B
89 CHD 12/25/2010 A
89 CHD 12/25/2010 B
90 CAD 1/11/2011 C
90 CAD 1/11/2011 D
90 CAD 1/14/2011 C
90 CAD 1/14/2011 D
90 CAD 1/17/2011 C
90 CAD 1/17/2011 D

;
run; 

 

The resulting output would look something like this:

 

DiagnosisFirstLine_RegimenFrequency (Count)
CADAB1
 B2
 CD1
CHDAA1
 AB2


I read other threads that nearly related to my question but couldn't quite derive a working code based off them. 

Help would be appreciated! Thanks.

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Always a good idea to specify the form of your desired result. This code gives you all your firstline treatments

 

proc sql;
   create table firstline_trt as
   select * from have
   group by id, diagnosis 
   having(trt_date)=min(trt_date);
quit;
Asquared
Calcite | Level 5

Hi @PeterClemmensen 

Just updated the question and added the desired output table. It would look something like this.

DiagnosisFirstLine_RegimenFrequency (Count)
CADAB1
 B2
 CD1
CHDAA1
 AB2
rajdesai
Calcite | Level 5

How do you create the frequency table?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 959 views
  • 0 likes
  • 3 in conversation