BookmarkSubscribeRSS Feed
Oleg_L
Obsidian | Level 7
Hello SAS-users.

I have no experience with annotate datasets. I'm trying to use annotate at first time.
I build a graph using Gchart procedure. See part 1 of the code below.
Now I need to add two lines at the same graph. I have tried to draw these lines by using annotate dataset.
See part 2 of the code below.
There are no errors in the Log. But the lines are not visualising in the output window.

What am I doing wrong?
Please help.

Oleg.

[pre]


/* Code part 1 */
/* input dataset for proc gchart */

data inp;
infile cards dlm=',';
informat date date9. cbmb11 $2. pct percent8.;
format date mmddyy10. pct percentn8.2;
input date cbmb11 pct ;
cards;
31DEC2009,CB, 0.00%
31DEC2009,MB, 0.00%
31JAN2010,CB, 1.87%
31JAN2010,MB, 3.31%
28FEB2010,CB, 2.09%
28FEB2010,MB, 0.05%
31MAR2010,CB, 2.01%
31MAR2010,MB, 0.81%
;

goptions reset=all;
title1 "Dynamic (%)" ;
axis1 color=black width=3 label=(color=black height=0.75 "%") minor=(number=1) value=(height=0.75) order=(0 to 0.07 by 0.01);
axis2 color=black width=3 label=(color=black height=0.75 "Date") value=(height=0.75);
goptions device=win cback=white ftext="Arial" htitle=1;
pattern1 color=blue value=r3 r=1;
pattern2 color=green value=l1 r=1;

/* Gchart proc. without annotate */

proc gchart data=inp ;
vbar cbmb11 / sumvar=pct width=8 group=date discrete gaxis=axis2 axis=axis1 frame sum patternid=midpoint space=0 ;
run;
quit;

/* Code part 2 */
/* Annotate dataset */

data an;
infile cards dlm=',';
informat xsys $1. ysys $1. hsys $1. function $8. color $8. group date9. x date9. y percent8. line 8. size 8.;
format group x mmddyy10. y percentn8.2;
input xsys ysys hsys function color group x y line size;
cards;
2,2,1 ,move , ,31DEC2009,31DEC2009, 0.00% , ., .
2,2,1 ,draw ,blue ,31JAN2010,31JAN2010, 1.87% , 2, 20
2,2,1 ,move , ,31JAN2010,31JAN2010, 1.87% , ., .
2,2,1 ,draw ,blue ,28FEB2010,28FEB2010, 4.00% , 2, 20
2,2,1 ,move , ,28FEB2010,28FEB2010, 4.00% , ., .
2,2,1 ,draw ,blue ,31MAR2010,31MAR2010, 6.09% , 2, 20
2,2,1 ,move , ,31MAR2010,31MAR2010, 6.09% , ., .
2,2,1 ,draw ,blue ,31MAR2010,31MAR2010, 6.09% , 2, 20
2,2,1 ,move , ,31DEC2009,31DEC2009, 0.00% , ., .
2,2,1 ,draw ,green ,31JAN2010,31JAN2010, 3.31% , 1, 5
2,2,1 ,move , ,31JAN2010,31JAN2010, 3.31% , ., .
2,2,1 ,draw ,green ,28FEB2010,28FEB2010, 3.37% , 1, 5
2,2,1 ,move , ,28FEB2010,28FEB2010, 3.37% , ., .
2,2,1 ,draw ,green ,31MAR2010,31MAR2010, 4.20% , 1, 5
2,2,1 ,move , ,31MAR2010,31MAR2010, 4.20% , ., .
2,2,1 ,draw ,green ,31MAR2010,31MAR2010, 4.20% , 1, 5
;

/* Gchart proc. with annotate */

proc gchart data=inp ;
vbar cbmb11 / sumvar=pct width=8 group=date discrete gaxis=axis2 axis=axis1
frame sum patternid=midpoint space=0 annotate=an ;
run;
quit;


[/pre]
2 REPLIES 2
GraphGuy
Meteorite | Level 14
When you're annotating on a gchart vbar, you need variables called 'midpoint' and 'y', rather than 'x' and 'y', I believe.

Here's a simple example that annotates a line on a bar chart, that might help:

http://robslink.com/SAS/democd31/shoebar.htm
http://robslink.com/SAS/democd31/shoebar_info.htm
Oleg_L
Obsidian | Level 7
Thank you very much for your help.

You pushed me in a right direction. I've achieved some progress. Lines are appeared. I will work on other details.

Regards,
Oleg.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 896 views
  • 0 likes
  • 2 in conversation