BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All,

I have a query to ask. I am in the process of annotating my gplot in sas 9.2. I have used reflabels to name my vref. The problem is the text is hardly visible with all the data. I have tried to change the colours to see if i can make it more visible. But it doesnt seem to work.

I was wondering if its possible to make the reflabels appear outside the plotted data ie the frame Message was edited by: neophyte
9 REPLIES 9
DanH_sas
SAS Super FREQ
Hey,

There are a few alternatives. If you stick with GPLOT, you may be able to set the axis length in a way to reserve space for an outside reflabel, and you can annotate the label. Instead of moving it outside, you may also be able to set an axis offset to make room for the label. Another alternative is to use SGPLOT instead, which has an option to put the refline labels inside or outside of the data area. If your interested in trying SGPLOT, just post more information about what you're trying to plot and I'll see if I can give you some SGPLOT code to make it.

Thanks!
Dan
deleted_user
Not applicable
HI Dan

Thanks for getting back to me. If I want to stick with gplot, how can i offset axis or set the axis length to make space for label?

In terms of SGPLOT, I am basically trying to plot varb-y against varb-x (so something like,http://upload.wikimedia.org/wikipedia/commons/9/91/Bush_disapproval_ratings_line_graph.png).

Sorry to be pain but if feasible, do you know if we can legend of vref rather than symbols, and if so how?

I was trying to search on net, but almost all the info on legends is with symbols or different lines (which requires different dataset). But mine just contains 1 dataset but with different vref's.

Thank you so much
GraphGuy
Meteorite | Level 14
I've created a little example that demonstrates how to control most of the things you're asking about...



axis1 reflabel=(h=12pt 'skinny' 'ok' 'fat');
axis2 offset=(0,2);

proc gplot data=sashelp.class;
plot height*weight /

haxis=axis1
href=(85 110 150)
chref=(red green purple)

vaxis=axis2
vref=(80)
cvref=(gray)
;
run; Message was edited by: Robert Allison @ SAS
DanH_sas
SAS Super FREQ
Here are a couple of simple SGPLOT examples to show you how to make external reflabels and how to put the reflines in a legend:

[pre]
proc sgplot data=sashelp.class;
scatter x=weight y=height;
refline 60 / labelloc=outside label="This is a label";
run;

proc sgplot data=sashelp.class;
scatter x=weight y=height;
refline 60 / labelloc=outside lineattrs=(color=blue) legendlabel="Value=60" name="r";
refline 70 / labelloc=outside lineattrs=(color=red) legendlabel="Value=70" name="s";
keylegend "r" "s";
run;
[/pre]
deleted_user
Not applicable
Hi Dan

I have tried to do what you suggested - but its still giving me problems and I cant figure out why. I have pasted below my code and my log accompained with it. (if this helps)

proc sgplot data=exp;
scatter x= dpdate y= CBSELFCALSLP;
refline &A / labelloc=outside lineattrs=refcurrslp pattern=3 thickness=2 color=grey LEGENDLABEL= "Label" name="r";
keylegend "r" ;
run;

Log:
394 proc sgplot data=exp;
395 scatter x= dpdate y= CBSELFCALSLP;
396 refline &ref_curr_slp / labelloc=outside lineattrs=refcurrslp pattern=3 thickness=2
-------
79
ERROR 79-322: Expecting a (.

396! refline &A / labelloc=outside lineattrs=refcurrslp pattern=3 thickness=2
396! color=grey LEGENDLABEL= "Label" name="Name";
-----------
79
ERROR 79-322: Expecting a ).
397 keylegend "r" "s";
398 run;


Also I wanted to ask if I wanted to have more than 1 refline (with different colours/patterns/thickness/labels), then do I have to create a new refline everytime or I can do as following:
refline &A &B &C… / labelloc=outside lineattrs=refcurrslp pattern=3 thickness=2 color=(grey black blue) LEGENDLABEL= ("LabelA" “LabelB”… name="A" “B”;
Andre
Obsidian | Level 7
Waiting Dan answer,
check ERROR 79-322: Expecting a (.
with a resubmit with mprint option
something in the text substitued by the way of a macro variable
is invalid at line 322 of your past submitted log

so you should perhaps find by your self the solution to your problem

Andre

and lineattr=( ) was written so in dan's code Message was edited by: Andre
Andre
Obsidian | Level 7
sure now
your problem is syntaxic

lineattrs=( )

see at page 1 of

From "Using PROC SGPLOT for Quick High-Quality Graphs" by Susan J. Slaughter and Lora D.
Delwiche, presented at SAS Global Forum 2010, Seattle, WA, paper 154-2010.

at
susanslaughter.files.wordpress.com/2010/04/sgplottables.pdf
DanH_sas
SAS Super FREQ
To fix our code, your line color, pattern and thickness should be in the ()'s:

[pre]
proc sgplot data=exp;
scatter x= dpdate y= CBSELFCALSLP;
refline &A / labelloc=outside lineattrs=(pattern=3 thickness=2 color=grey) LEGENDLABEL= "Label" name="r";
keylegend "r" ;
run;
[/pre]

The only thing that can be out of the parens is a style element reference.

To answer your other question, you can specify multiple values on a REFLINE statement (even a column variable), but they will all have the same attributes. For unique attributes, you have to use multiple statements.

Hope this helps!
Dan
deleted_user
Not applicable
Thanks Dan

You have been a great help.Thank you for replying back to my posts.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 2924 views
  • 0 likes
  • 4 in conversation