Hi,
I would like to seek help again on how am I suppose to create my desired output. What I want is similar to what is found on this example.
http://support.sas.com/kb/24/865.html
The additional thing I want is to put a label on the top of per dot to specify the value of the y. What I'm currently getting on my annotation is that it is placed on the right side of the dot. Would it be possible to place it on top instead?
Thanks!
Milton
Could you show what code you've added to get the annotations you're currently seeing to the right of the dots?
I assume you're using the annotate 'label' function. In combination with this function, you'll want to make sure you trim off leading & trailing blanks from your text ... text=trim(left(text)); ... and you'll probably want to use the annotate 'position' variable to make the text show up above the dot ... position='2'; (although if you want it to be even farther above the dot, sometimes you might even add a little bit of offset to the y-variable).
Could you show what code you've added to get the annotations you're currently seeing to the right of the dots?
I assume you're using the annotate 'label' function. In combination with this function, you'll want to make sure you trim off leading & trailing blanks from your text ... text=trim(left(text)); ... and you'll probably want to use the annotate 'position' variable to make the text show up above the dot ... position='2'; (although if you want it to be even farther above the dot, sometimes you might even add a little bit of offset to the y-variable).
Hi Dr. Allison,
You got it correct again thank you so much! My text had leading blanks on it. I just didn't understand how the position of '2' made it display on top of the plot.
By the way, I used the code on your oil industry example from your website to create my annotation data set. I added these after the second output statement.
function='label';text=target; size=1;y=target; position='2'; output;'
The target variable is numeric causing them to have leading blanks. I just recreated the annotation dataset to trim of the leadings blanks and there I got the display I wanted.
Many thanks again for your help!
Milton
Hi,
Now I have another concern. Now it actually works when I run it on Base SAS. But when I use this on a stored process the annotations won't appear. Currently it's on activex but when I change it to png or jpg the whole graph doesn't show up anymore.
How can I make it visible in the web?
Thanks!
Could you show the code you're using for the stored process? If you had hard-coded ODS statements to write to a file, you'll need to take those out. Also, to change the device, you have to set some special macro variables before you call the stpbegin macro.
Also, what settings did you use when you registered the stored process?
And are you running the stored process via a URL (stored process webapp url), or through the Portal, or through EG, or other?
Hi,
Please code below.
The setting for my stored process is streaming. I'm running this through a stored process portlet in portal.
data _null_;
file _webout;
put "<html>";
put "<head>";
put "</head>";
put "<body>";
put '<table border="1" width="100%">';
put '<tr><td width="80%">';
run;
%stpbegin;
goptions reset=all;
goptions cback=white device=activex vsize=3in hsize=10.5in transparency;
axis1 label=none;
axis2 label=none order=(0 to 100 by 20);
pattern1 v=solid color=cx007DC3; /* SELECTION */
pattern2 v=solid color=cxD16600; /* OTHERS */
legend1 label=none;
%let save_year = &save_year.;
data _null_;
ystart = mdy(1,1,&save_year.);
yend = intnx('year',ystart,0,'end');
call symput('ystart',ystart);
call symput('yend',yend);
run;
proc gchart
data=coll_merged_&_METAUSER.;
vbar month / sumvar=collections
subgroup=group
midpoints=&ystart. to ¥d. by month
anno=coll_anno_&_METAUSER
maxis=axis1
raxis=axis2
legend=legend1
width=6
;
format month monname3. collections comma25.0;
run;
quit;
%stpend;
data _null_;
file _webout;
put '</td><td>I'll be putting something else here';
put '</td></tr>';
put '</table>';
put "</body>";
put "</html>";
run;
Hmm ... let's simplify first, by getting rid of the data steps with the 'put' statements at the beginning & end of the program, just to get the graph & the annotation working first (divide & conquer - one problem at a time)...
Also, I notice you're using "goptions device=activex" -- although that works in DMS and Batch jobs, you have to set the device a different way in Stored Processes. Try the following code, and try changing the device between activex and png, and make sure it's doing what it should:
%let _GOPT_DEVICE=png;
%let _ODSOPTIONS=gtitle gfootnote style=sasweb;
%stpbegin;
/* run your proc g-whatever here */
%stpend;
Hi,
If I use png as the value for _GOPT_DEVICE the graph will display along with the desired annotations. However, the display got messed up. I've been trying to play with the other reserved macro variables which alter the resolution of the graph. Unfortunately I have failed to get my desired display. Below is the options I used, and the display I got. I tried to remove the vsize and hsize but I just got an almost similar output.
%global _odsdest _odsstyle _gopt_device _odsoptions _goptions _gopt_vsize _gopt_hsize;
%let _gopt_device=png;
%let _gopt_vsize=3in;
%let _gopt_hsize=6in;
%let _goptions=gunit=pct cback=white htext=4 ;
%let _odsdest=html;
%stpbegin;
axis1 label=none;
axis2 label=none;
pattern1 v=solid color=cx007DC3; /* SELECTION */
pattern2 v=solid color=cxD16600; /* OTHERS */
legend1 label=none position=(middle right) frame;
Thanks!
I haven't used stored processes much, so I'm no expert, but here are some things to try...
Does it work & look ok if you take out all the hsize/vsize specifications and just let it use the default png full size display (800x600 pixels, I think).
With device=png, I almost always use goptions xpixels & ypixels to control the size (rather than hsize & vsize). Maybe give that a try, and maybe try defining a larger display area (at least at first, until the bar chart layout is displaying ok ... and then try reducing the size until it ceases to fit). I guess you could use the _gopt_xpixels & _gopt_ypixels before you call stpbegin - but at least in early versions of the stored process when I was working with them, I set them after the stpbegin, such as ...
%let _GOPT_DEVICE=gif;
%let _ODSOPTIONS=gtitle gfootnote style=minimal;
%stpbegin;
goptions xpixels=400 ypixels=300;
/* proc gchart, etc */
%stpend;
Does your code run ok with dev=png *outside* of a stored process?
Another thing to try, to get the bar chart where it's fitting into the small space, it to reduce the font size (such as goptions ftext=1.5pct;) Once you get it drawing the chart ok, then you can slowly try increasing the size of the font to see how big you can get it before the chart can't draw itself.
And one question - I notice you're defining your macro variables as global variables. I'm not sure that hurts anything, but I've never seen that done - maybe try it without declaring them global, and see if that makes a difference.
... Sorry I don't have a definitive answer, but hopefully one of these tips will help! If none of them help, then perhaps it's time for a call to tech support
Hi,
I get error messages when I don't declare them as global variables that's why I had to put them before assigning a value.
Since I'm running out of time I just retained with my activex output since it displays neatly without the annotations however. Reason why annotations did not appear is I think it is not supported yet on 913 according to Problem Note 13691. How I wish client would just upgrade to 92 instead haha!
No need to be sorry. You actually took me to the next level when it comes to SAS graphs.
Thanks a lot for the help on this!
Also found a track raised by Angela when vbars have subgroups. It won't display the annotations.
Hi,
As I stated in my previous posts, the annotations do not reflect on the graph. However when we tried to view it on a different machine and probably a newer version of IE, it suddenly worked!
Must have been the activex driver installed on the development machine which causes me to get undesirable results.
Again thanks a lot for the help!
It appears you might be using some features that are supported in newer versions of SAS/Graph ActiveX control, but not in older versions.
If that's the case, it would be a good idea to set up your graphs such that they prompt the user to install the newer version, if they do not have it. You can set this up, using the technique described on this page:
http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#a002195362.htm
As investigated yeah it was the version of the activex control. On the dev machine it has the activex for 913. On the laptop where I saw the annotations displayed correctly it was 92 software installed.
Thanks for the link. Will try to implement that one.
You can produce this with the SGPLOT procedure without using annotation. See http://support.sas.com/documentation/cdl/en/grstatproc/62920/HTML/default/viewer.htm#n1mp0swy0atvzun...
For the KB example you link to, the example would look something like this:
data a;
input Xvar mmddyy6. Vbar_Y Plot_Y;
datalines;
010196 10 8
020196 20 15
030196 30 20
040196 40 36
050196 50 42
;
run;
proc sgplot data=a noautolegend;
format xvar monname3.;
format Vbar_Y dollar6.;
vbar xvar / response=Vbar_Y;
vline xvar / response=Plot_Y markers
datalabel=Plot_Y;
xaxis display=(nolabel); yaxis label="Sales";
run;
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: