Hi,
Attached is the spagetti plot that I made. Does anyone know how to add a smooth line (mean or median) to this figure?
Below is my SAS code:
proc sgplot data=test2;
where AKI=1 & survive_5yr = 1;
series x=year y=eGFR_a /group=ID ;
keylegend 'grouping' / type=linecolor;
label eGFR_a = eGFR year = Year;
run;
Many thanks in advance!
1. Do not attach MS Office files, many will/can not download these.
2. Include images as ... images, there's a button for that
3. Did you try adding a series statement?
4. It's a good idea to include code that we can run. For example using one of the sample data sets in the SASHELP library.
proc sgplot data=test2;
where AKI=1 & survive_5yr = 1;
series x=year y=eGFR_a /group=ID ;
loess x=year y=eGFR_a ;
keylegend 'grouping' / type=linecolor;
label eGFR_a = eGFR year = Year;
run;
It does not look like what I expected. I would like to plot a mean in the middle of the figure, if possible....
Mean or median of what exactly?
How many lines of spaghetti (group=ID values) are there? If you have 10 lines are you looking to add 10 "means"?
You
I might be tempted to add:
reg x=year y=eGFR_a /group=ID ;
to show a "best fit" line associated for each group.
Or summarize you data to find the desired mean or median and use a REFLINE statement to plot those values.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.
About cookies on this site
This site uses cookies and related technologies for site operation, analytics and third-party advertising purposes, as described in our SAS Privacy Statement. You may consent to our use of these technologies, reject non-essential technologies or further manage your preferences. To opt out of SAS making information relating to cookies and similar technologies available to third parties for advertising purposes, select "Required only." To exercise other rights you may have related to cookies, select "Manage cookies."