BookmarkSubscribeRSS Feed
fy1
Fluorite | Level 6 fy1
Fluorite | Level 6

Hi ,

I made an annotated dataset to try out the sgplot, and found the result is not what I expected, Could you tell me what i should do to make my existing annotated datasets are still valuable in new powerful procedure sgplot?   

 

Thank you so very much.

 

****************************************************************************;

data xx;
do Dt='1JAN2016'd to '1jan2017'd;
retain CNT 1;
cat1=rand('bernolli',0.3);
cat2=rand('bernolli',0.5);
mon=month(DT);
output;
end;
run;
proc means data=xx sum;
var CAT1 CAT2;
class MON ;
output out=res_cnt sum=/autoname;
run;

data plt;
set res_cnt;
x=_n_;
y=CAT1_sum;
if mon>.;
run;
%annomac;
data plt_anno ;
set plt;
%dclanno;
%line(0,0,10,10,black,1,1);
%line(0,0,12,22,black,1,1);
%line(0,0,22,33,black,1,1);
%line(0,0,32,44,black,1,1);

run;
axis1;
axis2;
proc ganno annotate=plt_anno;
title1 "ganno";
run;
proc gplot data=plt;
title1 "gplot";
plot y*mon/anno=plt_anno;
run;

proc sgplot data=plt sganno=plt_anno;
title1 "sgplot";
scatter x=mon y=y;
run;

***************************************************************************;

3 REPLIES 3
Reeza
Super User

The advantage to SGPLOT is that sometimes there's an easier/better way to do things.

 

Both codes generate a standard scatter plot but the GPLOT has some random lines? 

 

In SGPLOT I would consider using REFLINE/POLYGON/TEXT instead to mimic some of the functionality you had with the annotation sets. I'm not sure this would work in your exact situation/example.

 

Jay54
Meteorite | Level 14

Annotation in SGPLOT is NOT the same as in GPLOT.  You cannot use the same data set.  That is one reason the option name is called SGANNO, not ANNO.  See this article on some information.

 

That said, there are better ways to create graphs in SG procedures without use of annotation as alluded to by Reeza.  See Getting Started articles in Graphically Speaking Blog for many articles on using plot layers.  

fy1
Fluorite | Level 6 fy1
Fluorite | Level 6
Thanks, Sanjay and Reeza, I got it, The sgplot is not going to replace the gplot, we still need old annotate library to build some graphs like the example I randomly drew.

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 928 views
  • 0 likes
  • 3 in conversation