*
;

       options nosource;
%macro remarks (data,result,x,y,text,style,size,position);
       options nostimer nonotes nomprint nosymbolgen;

*written: June 26, 1995, Arnold Schick University of Marburg;

  %if &data =  and &result =  and &x =  and &y =  or
     %upcase(&data) = HELP or &data = ? %then %do;
     %put  This macro creates annotate data set;
     %put  for annotation of text within graphs;
     %put  and prepares axes-statements: horizontal: axis1, vertical: axis2;
     %put;
     %put  call: remarks (data,result,x,y,text,font,fontsize,position);
     %put;
     %put  with meanings and defaults: ;
     %put  data     : input data set [ _last_ ];
     %put  result   : output data set [ _anno_ ];
     %put  x        : variablename for abscissa in input data set [ x ];
     %put  y        : variablename for ordinate in input data set [ y ];
     %put  text     : variablename of textvariable [ text ] in data set;
     %put  font     : variablename of font [ style ] or fontname [ simplex ];
     %put  fontsize : variablename of fontsize [ size ] or fontsize [ 1 ];
     %put  position : variablename of position [ position ] or position [ 2 ] = center;
     %put  Please note, text should be defined in format $char30;
     %put ;
     %goto fin;
  %end;
  %if &data   =. %then %let data   = _LAST_ ;
  %if &data   =  %then %goto quit_1;
  %if &result = or &result = . %then %let result = _ANNO_  ;
  %if &x =  or &x = . %then %let x = x;
  %if &y =  or &y = . %then %let y = y;
  %if &text     =  or &text=.  %then %let text =text;
  %if &style    =  or &style=. %then %let style=simplex;
  %if &size     =  %then %let size= . ;
  %if &position =  or &position =. %then %let position=2;

data &result;
    set &data;
    retain function 'LABEL' xsys '2' ysys '2' style "&style"
           size &size position "&position" text ' ';
    keep function x y xsys ysys style size position text;
    x = &x;
    y = &y;
    text = &text;
run;

proc means data=&data;
  var &x &y;
  output out=_minmax_ min=min_x min_y max=max_x max_y;
run;
%let prop = %scan(&size,1,1234567890);
%if &prop ^=. %then %do;
data _NULL_;
  set _MINMAX_;
  dx = (max_x-min_x)*0.1;
  dy = (max_y-min_y)*0.1;
  call symput('min_x',min_x-dx*&size); call symput('min_y',min_y-dy*&size);
  call symput('max_x',max_x+dx*&size); call symput('max_y',max_y+dy*&size);
  call symput('dx',dx);                call symput('dy',dy);
run;
%end; %else %do;
data _NULL_;
  set _MINMAX_;
  dx = (max_x-min_x)*0.1;
  dy = (max_y-min_y)*0.1;
  call symput('min_x',min_x-dx); call symput('min_y',min_y-dy);
  call symput('max_x',max_x+dx); call symput('max_y',max_y+dy);
  call symput('dx',dx);          call symput('dy',dy);
run;
%end;

proc datasets nolist;
  delete _MINMAX_;
quit;

axis1 order=&min_x to &max_x by &dx;
axis2 order=&min_y to &max_y by &dy;

%goto fin;
%quit_1 : MACRO-HALT: %put input data set name is not present;
%fin : ;

options source stimer ;
%mend remarks;  options source;
/*
*Example;

data one;
  input x y size position $1. style $8. text $char30.;
  *drop size position style;
cards;
1 1 1.1 3 zapf    Text 1
2 2 0.6 2 simplex noch ein Text
3 2 1.2 4 zapfb   ein weiterer Text
3 3   2 7 brush   last text
;
run;

%remarks(one,remarks);

proc gplot data=one;
  symbol i=none v=star r=123;
  plot y*x / annotate=remarks
             haxis=axis1 vaxis=axis2
             nolegend noaxis;
run; quit;
*/
%remarks;

*
;