/* grafxy1y Daniel Brockman 070522 graph x, y1 and y variables */ %macro grafxy1y2(dsn,x,y1,y2,reg,line,title,footnote,name,gcat) ; /* * dsn is the name of the input data set * * x is the x variable to plot on the x-axis * * y1 is the 1st variable to plot on the y-axis * * y2 is the 2nd variable to plot on the y-axis * * reg =1 or Y or yes or TRUE means compute and draw linear * regression line and 95% confidence interval. * reg=1 overrides your choice for line. * * line =1 or Y or yes or TRUE means connect the dots with a line * =otherwise means no line. * * title A title for the chart * * footnote A footnote for the chart * * name name to attach to chart (see name plot option of proc gplot) * * gcat Output graphic catalog (gout) * * Choose the name of gcat as you would a dataset name. */ %global greturn; %local t1 t2 i j k; %local reg lin; * get temporary set names ; %getdsname(dsn); %let t2 = &greturn; data &t2 ; set &dsn ; if (missing(&x) or missing(&y1) or missing(&y2)) then delete ; run ; * remove missing obs ; * goptions ftext=swiss gsfmode=append rotate gprolog='%!' display ; * goptions device=gif; title h=2 "&title"; footnote h=1 "&footnote"; proc gplot data=&t2 gout=&gcat; symbol1 %let j = %upcase(&line) ; %if (&j=1 OR &j=TRUE OR &j=YES OR &j=YE OR &j=Y) %then %do ; /* if join dots */ i=join %end; /* if join dots */ %let j = %upcase(®) ; %if (&j=1 OR &j=TRUE OR &j=YES OR &j=YE OR &j=Y) %then %do ; /* if reg line */ i=rlcli95 %end; /* if reg line */ h=1 v=circle c=blue; * end of symbol1 clause; symbol2 %let j = %upcase(&line) ; %if (&j=1 OR &j=TRUE OR &j=YES OR &j=YE OR &j=Y) %then %do ; /* if join dots */ i=join %end; /* if join dots */ %let j = %upcase(®) ; %if (&j=1 OR &j=TRUE OR &j=YES OR &j=YE OR &j=Y) %then %do ; /* if reg line */ i=rlcli95 %end; /* if reg line */ h=1 v=square c=red; * end of symbol2 clause; * axis1 label="&x" ; * axis2 label="&y1 and &y2" rotate=90 ; plot &y2*&x &y1*&x/ /* haxis=axis1 vaxis=axis2 */ overlay name="&name." ; run; title ; footnote ; * reinit ; * remove tempo datasets; %delds(&t2); %mend grafxy1y2; ;