Hi everyone,
is there a way to plot recurrent events? or What is the best way to plot adverse events. I am looking to create a plot like this.
May be one difference that adding two or more symbols for different types of recurrent events.
My data structure is very simple like this: ID, EventNr, EventType, EventDate.
Event type can either be recurrent event, terminal event or study exit.
Any ideas?
Thx
Here's one way to do it (I'm generating fake/random data, to be somewhat like the data in your graph)...
data my_patients (drop=id_num);
do id_num=1 to 100;
length id $10;
id=id_num;
time=ranuni(123)*2000;
output;
end;
run;
proc sort data=my_patients out=my_patients;
by descending time;
run;
data my_patients; set my_patients;
events=round(10*ranuni(123));
do eventnr=1 to events;
eventtype='Recurrent Events';
eventdate=ranuni(123)*time;
output;
end;
if ranuni(123)<.3 then do;
eventtype='Terminal Event';
eventdate=time;
output;
end;
run;
data myattrmap;
id='scattersymbols';
length markersymbol value markercolor $50;
value='Recurrent Events'; markercolor='cx83a37b'; markersymbol='circlefilled'; output;
value='Terminal Event'; markercolor='red'; markersymbol='trianglefilled'; output;
run;
title j=l "Recurrent Event Plot";
proc sgplot data=my_patients noborder dattrmap=myattrmap;
label id='Subject';
hbarparm category=id response=time / fillattrs=(color=graycc) outlineattrs=(color=gray99);
scatter y=id x=eventdate / group=eventtype attrid=scattersymbols;
yaxis display=(novalues noticks noline);
run;
If your data was less dense, I would suggest using a HIGHLOW plot, like in Sanjay's post here (https://blogs.sas.com/content/graphicallyspeaking/2013/01/30/ae-timeline-by-name/). However, given the amount of data you have, you might want to do something like this (untested code below):
proc sgplot data=ae_data noborder;
hbarparm ID / response = EventDate;
scatter y=ID x=EventDate / group = EventType;
run;
Hope this helps!
Dan
Here's one way to do it (I'm generating fake/random data, to be somewhat like the data in your graph)...
data my_patients (drop=id_num);
do id_num=1 to 100;
length id $10;
id=id_num;
time=ranuni(123)*2000;
output;
end;
run;
proc sort data=my_patients out=my_patients;
by descending time;
run;
data my_patients; set my_patients;
events=round(10*ranuni(123));
do eventnr=1 to events;
eventtype='Recurrent Events';
eventdate=ranuni(123)*time;
output;
end;
if ranuni(123)<.3 then do;
eventtype='Terminal Event';
eventdate=time;
output;
end;
run;
data myattrmap;
id='scattersymbols';
length markersymbol value markercolor $50;
value='Recurrent Events'; markercolor='cx83a37b'; markersymbol='circlefilled'; output;
value='Terminal Event'; markercolor='red'; markersymbol='trianglefilled'; output;
run;
title j=l "Recurrent Event Plot";
proc sgplot data=my_patients noborder dattrmap=myattrmap;
label id='Subject';
hbarparm category=id response=time / fillattrs=(color=graycc) outlineattrs=(color=gray99);
scatter y=id x=eventdate / group=eventtype attrid=scattersymbols;
yaxis display=(novalues noticks noline);
run;
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.