I have used NLIN to model gas production curves using three different functions (Gompertz, Logistic, and LogLogistic). I am displaying the Raw Observations and the predicted curves on a graph. I am able to control colors of the lines but am not sure how to label them on the graph. The code I am using is shown below. It generates graphs that each contain 4 lines, as specified, but there is no legend.
Any help you could provide would be appreciated.
proc sort data=plot;by Treatment Replicate time;
ods graphics/height=6 in width=10 in noborder outputfmt=png ANTIALIASMAX=5600;
Title 'Gas Production';
proc sgpanel data=plot noautolegend;by Replicate;
label GasProd='Data' y_log_logistic='Log-logistic curve' y_logistic='Logistic curve' y_Gompertz='Gompertz curve'
ms_log='Log-logistic MS' ms='Logistic MS' ms_Gomp='Gompertz MS';
panelby Treatment/headerbackcolor=white novarname rows=1 columns=1;
series x=time y=GasProd/lineattrs=(color=gray pattern=1) group=Replicate;
series x=time y=y_log_logistic/lineattrs=(color=blue pattern=2) group=Replicate;
series x=time y=y_logistic/lineattrs=(color=red pattern=2) group=Replicate;
series x=time y=y_Gompertz/lineattrs=(color=green pattern=2) group=Replicate;
inset ms ms_log ms_Gomp/position=bottomright ;
If you remove the NOAUTOLEGEND option, does it give you something reasonable?
proc sgpanel data=plot noautolegend;by Replicate;
Here are some thoughts:
Hope this helps!
You also could try CURVELABEL= option to make your graph look pretty.
proc sgpanel data=sashelp.stocks NOAUTOLEGEND ;
panelby stock/onepanel columns=1;
series x=date y=close/curvelabel='close' curvelabelpos=max;
series x=date y=open/curvelabel='open' curvelabelpos=max;
run;
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.