BookmarkSubscribeRSS Feed
Quartz | Level 8

HI All,


I need to generate a Graph for AE data for each subject considering AE Start, End date, Relation, Action taken and AE Outcome. Please refer sample Graph attached. I am using SAS 9.4


I have a derived dataset of AEstdy and AEenddy. (Ex: AEstdy=5 means AE started n 5th day from the first dose given) 



   1. X-Axis should be have data points from AE start and end day. Ex: consider 0 to 200.

    2. Y axis should be grouped with Adverse event.

    3. For each subject we should have a separate page where we have to show the vector line from which day it started till ended. also we have to show Relation, Action taken and AE Outcome, Severity on top of the vector line with some codes (1,2,3 for actual values) and we should indicate these codes in the form of legends at the end of the page to understand.


please refer attached image where I need similar Graph , request you to help me on this. Please consider similar variable names and provide SGPLOT code get this kind of Graph.


Rhodochrosite | Level 12

Start by going to Graphically Speaking and searching for "Adverse Event".


Also see 

Super User
You should search LexJansen where people have published their code for these types of graphs. If you want code that conforms to your data structure you should post sample data. And yes, I understand your data is confidential, so please take the time to mock up some fake data that represents your data structure.
Quartz | Level 8

Hi Reeja,


Thanks for response. please see mock data below. Also see the expected graph in the attachment.  Please check and provide code.


SubAE TermStart DTEnd DtRelationRelation CodeAction takenAction CodeOutcomeOutcome CodeAE Start dayAE End day
100ABC  yes2None1recovered1754
100CDE  No1None1resolving21219
100ache  No1Interrupted2resolving23344
100aaaa  yes2Interrupted2resolving21218
100gggg  yes2Discon3resolving22255
100eeee  No1None1recoverd11314
100tttt  No1None1resolving21619
100yyyyy  yes2Discon3recoverd1420
Super User

I'm sorry, I can't write the code for you - I don't know how and can't spend that much time on this question. 


Your graph in the Word Doc is unclear and your data appears unsummarized at this point. I'm not sure if the graph requires the detailed level so you may want to pre-summarize your data to graph. I did do a quick search on lexjansen earlier and did find many different examples that can help you get started. 

Pyrite | Level 9



Simply put, if you want someone to do your job for you, then you can't expect a free forum to provide you with help. However, there are SAS conference papers galore that will give you code to do what you want at, or you could search SAS Blogs like Graphical Speaking, or indeed my own blog at includes a paid-for forum for answers to SAS-related questions.


To be a SAS programmer you have to be self-sufficient, and part of that is to be able to solve your own problems yourself by searching the available documentations and papers!



Philip R Holland
Holland Numerics: Blog and Forums



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 4 in conversation