I am attempting to draw a spaghetti plot that has a single line per subject but some subjects change groups during the study period (crossover) - for this subject, I want the single line to be two colors (eg red when group 1 and blue when group 2). How can I go about doing this? My current code is below not achieving the desired results. Basically for patients who switch treatment groups mid-study their line color should change when they switch. Thanks so much.
proc sgplot data=data; title 'Study Results by Treatment Group'; series x=Time y=Score / group=patient grouplc=arm name='grouping'; keylegend 'grouping' / type=linecolor; run;
Thanks to both of you. I actually stumbled upon that post incidentally this weekend.
So it seems if I have 100s of subjects I have to manually code every one of their lines?
Depends on how you define manually coding, but you should be able to have a data driven solution - I would assume you could use some basic IF/THEN statements to create your data appropriately.
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.
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.