BookmarkSubscribeRSS Feed
Naviava1973
Calcite | Level 5

Hi All,

I would like to generate a spaghetti plot for individuals on follow-up (having a continuous outcome)  and thereafter overlay an overall line of median (with quartile ranges) providing a summary of the outcome measures at each visit. I would also like to join the median values from baseline to the last visit (have 6 visits).

I can do the spaghetti plot fine without difficulty but I was wondering if someone can point me to a similar example.

 

My code so far looks like this:

 

proc sgplot data=ec noautolegend;
series x=years_on_follow_up y=cd4 / group=studyid LINEATTRS=(color=black pattern=1);
reg x=year y=cd4 / nomarkers lineattrs=(color=red);

xaxis label = "Years on follow-up";
yaxis label = "CD4 Count" ;
run;

 

Any thoughts and suggestions will be appreciated.

 

Ken

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You can add (overlay) multiple graphs on the same plot, so its just a matter of adding the data you want to the dataset, and adding additional plot statements.  Assume that your data contains median_base median_visit in your data, then you could just add:

proc sgplot data=ec noautolegend;
  series x=years_on_follow_up y=cd4 / group=studyid LINEATTRS=(color=black pattern=1);
  reg x=year y=cd4 / nomarkers lineattrs=(color=red);
  series x=median_base y=median_visit;
xaxis label = "Years on follow-up";
yaxis label = "CD4 Count" ;
run;

Or something like that to get the extra line.

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 1 reply
  • 587 views
  • 1 like
  • 2 in conversation