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;
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;
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.
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;
I'm using 9.4 TS1M5
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.
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.
You must using SAS OnDemand for Academic .
I have the same problem . Don't know why .
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 😞
@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 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;
Hi:
Using CURVELABELLOC and CURVELABELPOS worked for me in Display Manager using 9.4M5:
Cynthia
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!
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.