BookmarkSubscribeRSS Feed
somebody
Lapis Lazuli | Level 10

I want to have label at the end of the curves. however, the label does not display. It used to work but not anymore and I dont know how. Here is my code:

	proc sgplot data = stats;
			series x=t y=cum_r_excess/group=decile curvelabel curvelabelpos=end ;
			xaxis grid VALUES = (-32 TO 32 BY 1);
			yaxis GRID ;
			refline 0/ axis=y ;
		run; 

 

15 REPLIES 15
Reeza
Super User
What does the log show? Can you replicate the issue with a data set we can access, like sashelp.stocks. If this is data related, we won't be able to tell otherwise.
somebody
Lapis Lazuli | Level 10

Here is what I get when trying with sashelp.stocks:

 proc sgplot data = sashelp.stocks;
series x=date y=adjclose/group=stock curvelabel curvelabelpos=end ;

yaxis GRID ;
refline 0/ axis=y ;
refline 0/ axis=x ;
run;

sashelp_stocks.png

 

and here is the log:

NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.15 seconds
      cpu time            0.03 seconds

NOTE: The column format DATE7 is replaced by an auto-generated
      format on the axis.
NOTE: There were 699 observations read from the data set
      SASHELP.STOCKS.
Reeza
Super User

What version of SAS are you using? I initially thought it wasn't appearing but instead realized it was putting it at the beginning. I set it to Max instead and got what I think you want:

 

proc sgplot data=sashelp.stocks;
    series x=date y=adjclose/group=stock curvelabel curvelabelpos=max;
    yaxis GRID;
    refline 0/ axis=y;
    refline 0/ axis=x;
run;

Screen Shot 2019-05-23 at 9.18.45 PM.png

 

I'm using 9.4 TS1M5

somebody
Lapis Lazuli | Level 10

I am using SAS 9.4 (TS1M5).

I used your code but still could not get the labels. I used to be able to produce what I wanted on the same computer but for some reason, the labels don't appear this time. 

Reeza
Super User

Try adding some curvelabelattrs and curvelabelloc. 

I don’t know why but that seems to change the behaviour.

I just used the examples from the documentation for the attributes. 

 


@somebody wrote:

I am using SAS 9.4 (TS1M5).

I used your code but still could not get the labels. I used to be able to produce what I wanted on the same computer but for some reason, the labels don't appear this time. 


 

 

Ksharp
Super User

You must using SAS OnDemand for Academic .

I have the same problem . Don't know why .

Reeza
Super User
Agreed, not working on SAS Academics on Demand. That's gotta be a bug somewhere.
somebody
Lapis Lazuli | Level 10

I used the exact same code on my laptop and it works fine. It does not work (i.e. show the labels) when I used it on my PC at work. Please help 😞

Reeza
Super User
You need to talk to tech support, this is a bug. Please file a support ticket and let them deal with this. Would love to see the response as well. You can refer them to this link with both Cynthia and my posts it's pretty clear.
ballardw
Super User

@somebody wrote:

I want to have label at the end of the curves. however, the label does not display. It used to work but not anymore and I dont know how. Here is my code:

	proc sgplot data = stats;
			series x=t y=cum_r_excess/group=decile curvelabel curvelabelpos=end ;
			xaxis grid VALUES = (-32 TO 32 BY 1);
			yaxis GRID ;
			refline 0/ axis=y ;
		run; 

 


From the documentation for Curvelabel a possible hint:

Interactions If you specify VALUES=, MAX=, or MIN= in an axis statement, the points used to determine the position of the curve label might fall outside the graph area. In this case, the curve label might not be displayed, or its position might not be correct.

One work around:

Add some records with X Y coordinates in the same scale and desired Text , add a TEXT plot to overlay

Or an annotate data set doing basically the same thing possibly based on the first or last record for each group

 

Reeza
Super User
Except that exact code in SAS UE works and displays the labels.
ballardw
Super User

@Reeza wrote:
Except that exact code in SAS UE works and displays the labels.

 

Perhaps that comment about not displayed or wrong position is dependent upon version?!?

 

When I run the following which used the default position curvelabelpos, no option set, and an xaxis statement with Values= then no curvelabel appears running in Display Manager. So there appears to be significant differences in behavior with options.

proc sgplot data=sashelp.stocks;
    series x=date y=adjclose/group=stock curvelabel ;
    xaxis values=('01Jan2005'd to '01Jan2006'd by month);

    yaxis GRID;
    refline 0/ axis=y;
    refline 0/ axis=x;
run;

 

 

SGPlot1.png

 

Reeza
Super User
Both SAS UE and Academics on Demand are M5 aren't they? I suppose SAS UE could be M6 but the exact code gave different results with the exact same specifications and option set. And there are no warnings in the log, so this would definitely fall under unexpected behavior, whether its a feature or bug is unknown 🙂
Cynthia_sas
Diamond | Level 26

Hi:

  Using CURVELABELLOC and CURVELABELPOS worked for me in Display Manager using 9.4M5:

curvelabelpos.png

 

Cynthia

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 15 replies
  • 3801 views
  • 0 likes
  • 5 in conversation