BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ubai
Quartz | Level 8

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

 

plot-reSurv-1.png

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

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;

 

 

event_graph.png

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

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

GraphGuy
Meteorite | Level 14

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;

 

 

event_graph.png

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1757 views
  • 3 likes
  • 3 in conversation