****************************************************************************************************
****************************************************************************************************
* PROGRAM: figure_axes.sas
* Created (mm/dd/yyyy): 09/08/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: The macro computes X and Y axis tick marks
* - figuresub: figuresub from figurefile
* - where: where clause to restrict figure data
* - xtickmarks: macro variable name for x tick mark list
* - xvar = variable with xaxis metric
* - ytickmarks: macro variable name for y tick mark list
* - yvar= variable with yaxis metric
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro figure_axes(data=, figure=, figuresub=, where=, xtickmarks=, xvar=, ytickmarks=, yvar=);
%put =====> MACRO CALLED: figure_axes;
/*select min and max value from input dataset for x axis*/
%if %str(&xtickmarks) ne %str() %then %do;
select min(&xvar.), max(&xvar.) into :datamin, :datamax
from &data(where=(&where.));
%if %str(&yvar.) ne %str() %then %do;
select max(&yvar.) into :datamax
from &data(where=(&where.));
/*Extract axis parameters from figurefile*/
set figurefile(where=(figure="&figure." and figuresub="&figuresub"));
/*set min/max defaults if missing*/
%if %str(&xtickmarks) ne %str() %then %do;
if missing(xmin) then xmin = &datamin.;
if missing(xmax) then xmax = &datamax.;
%if %str(&ytickmarks) ne %str() %then %do;
if missing(ymin) then ymin = 0;
%if %str(&yvar.) = %str() %then %do;
if missing(ymax) then ymax = 1;
if missing(ymax) then ymax = round(&datamax.+4,10); /*to prevent cut off data*/
/*set default tick if missing:
- 6 total tick marks (min, max, and 4 interim)
- for x axis - round to the nearest divisor of 1, 5, or 30
depending on length of axis
- for y axis - round to nearest divisor of 10 */
%if %str(&xtickmarks) ne %str() %then %do;
if missing(xtick) then do;