BookmarkSubscribeRSS Feed
jsd1
Calcite | Level 5

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 ;

4 REPLIES 4
Quentin
Super User

If you remove the NOAUTOLEGEND option, does it give you something reasonable?

 

proc sgpanel data=plot noautolegend;by Replicate;
DanH_sas
SAS Super FREQ

Here are some thoughts:

  1. Remove the GROUP option from your SERIES plots. You are already subsetting the Replicate in the PANELBY statement, and you are setting the plot attributes on each statement. Removing the GROUP will clean up some possible behavior issues.
  2. Now that you've removed GROUP, do what @Quentin said and remove the NOAUTOLEGEND option from the SGPANEL statement. The legend will put all four SERIES plots in the legend (the GROUP option would have put only the first GROUP series plot in the legend).
  3. Use the LEGENDLABEL option on each SERIES plot to customize the legend label for each SERIES plot.

Hope this helps!

jsd1
Calcite | Level 5
Awesome--- that took care of it!

Ksharp
Super User

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;

Ksharp_0-1745982591615.png

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 990 views
  • 2 likes
  • 4 in conversation