BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Anna_h
Calcite | Level 5

How do I add these RED arrows on the x-axis?  I have my plot ready, except not knowing how to add those pointers.  Any suggestion?

figure-with-arrow.gif

Anna_H

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

If you want to go with a simple sas/graph software font (rather than a smooth/truetype/anti-aliased operating system font), you could use the arrow character (character 'K') from the sas/graph 'marker' font.

style='marker'; text='K';

Here's a list of the sas/graph software fonts:

SAS/GRAPH(R) 9.2: Reference, Second Edition

View solution in original post

12 REPLIES 12
snoopy369
Barite | Level 11

That could be done pretty easily with Annotations.  What are you using to create the graph?  GPLOT?

Anna_h
Calcite | Level 5

Yes, gplot with annotation.  Here is what my code looks like. how do I add these rarrows?

Options.....

legend label=none value=(font='swiss' h=9
        tick = 1  j=l "50 mcg C. diff "    
         .........;

axis1 label=(angle=90 font='swiss' h=11 "Antibody Concentration (Neut units/mL)" )
         order=(1 10 100 1000 10000 100000)
         value=(font='swiss' h=10 tick=1 "1"  tick=2 "10" tick=3 "100" tick=4 "1000" tick=5 "10000" tick=6 "100000")
         minor=none offset=(2,0.2) logbase=2 interval=uneven logstyle=expand;

axis2 label=(font='swiss' h=11 j=c 'Time (Days)')
      order= (0 to 240 by 30);
      value=(font='triplex' h=10 tick=1 "Baseline" tick=2 "Day 14" tick=3 "Month 1" tick=4 "Day 37" tick=5 "Month 2" tick=6 "Month 6"
           tick=7 "Day 187" tick=8 "Month 7") w= 1 minor=none offset=(20,20) interval=uneven;

     symbol1  interpol=join value = dot  color=red line=1   h=8;
            ...

proc gplot data=f_final;

   plot mean*xaxi=trt01pn/ legend=legend haxis=axis2 name="&pgmname   " des=""
          vaxis=axis1 noframe;
run;


snoopy369
Barite | Level 11

Something like this:

data annotateds;
length function $8;
angle=-90;
color='Red';
line=1;
size=1;
style='open';
xsys='2';
ysys='2';
function='move';
x=100;
y=-10;
output;
function='arrow';
y=5;
output;
function='move';
x=300;
y=-10;
output;
function='arrow';
y=5;
output;
function='move';
x=700;
y=-10;
output;
function='arrow';
y=5;
output;
run;

ods preferences;
proc gplot data=sashelp.prdsale annotate=annotateds;
plot actual*predict;
run;
quit;
ods html close;
GraphGuy
Meteorite | Level 14

Since you only need very short arrows, you don't really need to use the move/arrow technique (that would be for drawing long arrows).  In this case you can use the annotate 'label' function, and an arrow character from any font.  Here's an example...

data annotateds;
length function $8;

function='label'; color='Red'; size=4; hsys='3';
style='Wingdings 3'; text='8f'x;
ysys='1'; y=1.5;
xsys='2';
x=100; output;
x=300; output;
x=700; output;
run;

proc gplot data=sashelp.prdsale annotate=annotateds;
plot actual*predict;
run;

foo.png

Anna_h
Calcite | Level 5

I am unable to add this function="label" into my existing annotationds. But I add dummy treatment group (trt=99) into the original data before annotation.  It seems work except it shows in the legend.  How can I get ride of the bottom legend (red arrows) ? 

f_1_test.png

GraphGuy
Meteorite | Level 14

Using annotated arrows is (imho) the best & most direct way to go. Could you give a little more details about the problem you were getting with them?  Were you getting errors?

When you add the arrows by adding a dummy treatment group (ie, plotting fake data obsns), I don't know of a way to suppress that single legend item in the gplot legend. You could perhaps draw a white box over that legend item using annotate ... but if you're going to use annotate then you might as well annotate the arrows instead Smiley Happy

Anna_h
Calcite | Level 5

The bold italic is the added treatment (plot as red arrow).  How do I do it my annotation instead for these "Red Arrow" ?

Thanks!

data f_final;
   .......
  if avisitn=0 then xaxi=xaxi; *avisitn;
  else if xaxi >. then do;
    if trt01pn=1 then xaxi=xaxi;
    if trt01pn=2 then xaxi=xaxi+0.5;
    if trt01pn=3 then xaxi=xaxi+1; ;
    if trt01pn=4 then xaxi=xaxi+1.5;
    if trt01pn=5 then xaxi=xaxi+2;
    if trt01pn=6 then xaxi=xaxi+2.5;
    if trt01pn=7 then xaxi=xaxi+3;
   if trt01pn=8 then xaxi=xaxi;
  end;
run;


data anno;
length function $8 ;
  retain xsys ysys '2';
  set f_final;
  if trt01pn <9;

  if xaxi>0 then do;
  function='move';xsys='2';ysys='2';x=xaxi; y=lclm;size=1; line = 1; output;
  function='draw';xsys='2';ysys='2';x=xaxi; y=uclm;size=1; line = 1; output;
  end;

  function='move'; if xaxi ne . then x=xaxi+0.1; if uclm ne . then y=uclm+0.1; output;
  function='label'; if xaxi ne . then x=xaxi; if uclm ne . then y=uclm+0.3; size=0.5; style = "special"; text=""; ;output;

  if xaxi>0 then do;
%LINE (xaxi-5, lclm, xaxi+5, lclm, black, 1, 1);
%LINE (xaxi-5, uclm, xaxi+5, uclm, black, 1, 1);
end;
run;

GraphGuy
Meteorite | Level 14

It's probably easiest to create the annotate data set for the arrows separately from your other annotate data set, rather than trying to create it all at the same time.  You can combine the 2 annotate data sets into one later, or you can specify 2 different annotate data sets in your gplot ...

For example, if you have anno1 and anno2 data sets, you could combine them:

data anno_combined; set anno1 anno2;

run;

proc gplot data=foo anno=anno_combined;

plot y*x;

run;

Or you could specify them separately:

proc gplot data=foo anno=anno1;

plot y*x / anno=anno2;

run;

Anna_h
Calcite | Level 5

Got annotation working, but warning "font Winding could not be used"..

What other fonts that I can use to create down arrow?

GraphGuy
Meteorite | Level 14

Are you on a PC, and does it have the Wingding font?

What version of SAS are you using? (older versions might not be able to use the OS fonts)

If you're using SAS 9.3 on a Windows PC, the above code should work.

If not, we'll need to know more about your installation...

GraphGuy
Meteorite | Level 14

If you want to go with a simple sas/graph software font (rather than a smooth/truetype/anti-aliased operating system font), you could use the arrow character (character 'K') from the sas/graph 'marker' font.

style='marker'; text='K';

Here's a list of the sas/graph software fonts:

SAS/GRAPH(R) 9.2: Reference, Second Edition

Anna_h
Calcite | Level 5

I work on Unix sas 9.1.3.

style='marker'; text='L' works well.

Thank you so much every question answered perfectly!!

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
  • 12 replies
  • 4639 views
  • 0 likes
  • 3 in conversation