BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
genemroz
Quartz | Level 8

Esteemed Advisers:

 

I'm trying but failing to get annotate a scatterplot with arrows.  Below is a simplified version of my code that demonstrates the problem.  Probably a simple fix that I'm just not seeing.

 

Thanks in advance for your help,

 

Gene

 

options mprint symbolgen;

/*Create scatter plot dataset*/
data work.plot_data;
	input lat lon alt;
	datalines;
34.0 -105.0 120
33.0 -104.0 120
;
run;

/*Create arrow dataset file*/
data work.arrow_data;
	input latbeg lonbeg latend lonend;
	datalines;
34.5 -105.5 34.0 -105.0
33.5 -104.5 33.0 -104.0
;
run;

/*Create arrow_anno dataset*/
data arrow_anno;
set work.arrow_data;
retain xsys ysys '2' hsys '3' when 'a';
function='arrow';
x1=lonbeg;
y1=latbeg;
x2=lonend;
y2=latend;
color='black';
line=2;
size=.7;
style='FILLED';
run;

ods graphics;
/*Generate plot*/
proc sgplot data=work.plot_data sganno=arrow_anno aspect=1;
Title "Anno Arrow Test";
	scatter x=lon y=lat;
	xaxis grid min=-106 max=-103 minorgrid;
	yaxis grid min=30 max=35 minorgrid;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14
data plot_data;
input lat lon alt;
datalines;
34.0 -105.0 120
33.0 -104.0 120
;
run;

data arrow_data;
input latbeg lonbeg latend lonend;
datalines;
34.5 -105.5 34.0 -105.0
33.5 -104.5 33.0 -104.0
;
run;

data arrow_anno; set arrow_data;
function='arrow';
shape='filled';
layer='front';
linecolor='black';
linethickness=1;
drawspace='datavalue';
x1=lonbeg;
y1=latbeg;
x2=lonend;
y2=latend;
run;

proc sgplot data=plot_data sganno=arrow_anno aspect=1;
Title "Anno Arrow Test";
	scatter x=lon y=lat;
	xaxis grid min=-106 max=-103 minorgrid;
	yaxis grid min=30 max=35 minorgrid;
run;

anno_arrow.png

View solution in original post

3 REPLIES 3
Jay54
Meteorite | Level 14

The SGANNO feature uses a different data set than the SAS/GRAPH Annotation data set.

You need different variable names and values.

See:  https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n17wm229xfidj7n1nfx67jsb3yj5.htm

 

Also see for overview :   https://support.sas.com/rnd/datavisualization/papers/Annotate_Your_SGPLOT_Graphs.pdf

 

Also note, you could easily use the VECTOR plot or SERIES plot in your use case.

GraphGuy
Meteorite | Level 14
data plot_data;
input lat lon alt;
datalines;
34.0 -105.0 120
33.0 -104.0 120
;
run;

data arrow_data;
input latbeg lonbeg latend lonend;
datalines;
34.5 -105.5 34.0 -105.0
33.5 -104.5 33.0 -104.0
;
run;

data arrow_anno; set arrow_data;
function='arrow';
shape='filled';
layer='front';
linecolor='black';
linethickness=1;
drawspace='datavalue';
x1=lonbeg;
y1=latbeg;
x2=lonend;
y2=latend;
run;

proc sgplot data=plot_data sganno=arrow_anno aspect=1;
Title "Anno Arrow Test";
	scatter x=lon y=lat;
	xaxis grid min=-106 max=-103 minorgrid;
	yaxis grid min=30 max=35 minorgrid;
run;

anno_arrow.png

genemroz
Quartz | Level 8
Yes, I get confused about the different syntax for the different annotate systems.

Thanks for your help,

Gene

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 771 views
  • 2 likes
  • 3 in conversation