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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.