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:
Diagnosis | FirstLine_Regimen | Frequency (Count) |
CAD | AB | 1 |
B | 2 | |
CD | 1 | |
CHD | AA | 1 |
AB | 2 |
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.
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;
Just updated the question and added the desired output table. It would look something like this.
Diagnosis | FirstLine_Regimen | Frequency (Count) |
CAD | AB | 1 |
B | 2 | |
CD | 1 | |
CHD | AA | 1 |
AB | 2 |
How do you create the frequency table?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.