****************************************************************************************************
* PROGRAM OVERVIEW
****************************************************************************************************
*
* PROGRAM: figure_t5_output.sas
* Created (mm/dd/yyyy): 09/08/2021
*
*--------------------------------------------------------------------------------------------------
* PURPOSE: Produce type 5 figures F1-F3
*
* Program inputs:
* - figure123.sas7bdat
*
* Program outputs:
* - N/A
*
* PARAMETERS:
* -figure: figure
* -figurenum: figure number for report
* -figureletter: figure letter for report
* -title: figure title
* -where: where clause to restrict figure123.sas7bdat
* -figuresub: row in figurefile to produce table
* -yaxislabel1: Label for primary Y axis
* -yaxislabel2: Label for secondary Y axis
* -yvar: variable to use in plot
*
* Programming Notes:
*
*
*--------------------------------------------------------------------------------------------------
* CONTACT INFO:
* Sentinel Coordinating Center
* info@sentinelsystem.org
*
***************************************************************************************************;
%macro figure_t5_output(figure=, figurenum=, figureletter=, title=, where=, figuresub=, yaxislabel1=, yaxislabel2=, yvar=);
%put =====> MACRO CALLED: figure_t5_output;
/*Save dataset to REPORTDATA folder*/
%isdata(dataset=repdata.figure&figurenum.&figureletter.);
%if %eval(&nobs.<1) %then %do;
data repdata.figure&figurenum.&figureletter.;
set figure123(where=(&where.));
run;
%end;
/*stratified plot - collapse strata to determine correct Y axis*/
%let axisdata = repdata.figure&figurenum.&figureletter.;
%if &figuresub. ne overall %then %do;
proc sql noprint;
create table _collaspseddata as
select mntsfromstart, sum(&yvar.) as &yvar.
from repdata.figure&figurenum.&figureletter.
group by mntsfromstart;
quit;
%let axisdata = _collaspseddata;
%end;
/* Obtain y axis values */
%let t5ytickmarks = ;
/*assign axes - compute Y axis and maximum month for xaxis*/
%figure_axes(data=&axisdata., figure=&figure., figuresub=&figuresub., where=1 , xtickmarks=, xvar=, ytickmarks=t5ytickmarks, yvar=&yvar.);
proc sql noprint;
select max(mntsfromstart) into :datamax
from &axisdata.;
quit;
proc datasets nowarn noprint lib=work;
delete _collaspseddata;
quit;
ods startpage = now;
ods startpage = no;
ods graphics / height=7in;
/* Trick Excel into making a new sheet */
%if &destination. = excel %then %do;
ods excel options(sheet_interval="table");
ods exclude all;
data _null_;
file print;
put _all_;
run;
ods select all;
%end;