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-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
  • 974 views
  • 3 likes
  • 3 in conversation