****************************************************************************************************
****************************************************************************************************
* PROGRAM: l2_psdistribution_output.sas
* Created (mm/dd/yyyy): 03/17/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: The macro creates both aggregated and DP specific PS histograms
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro l2_psdistribution_output;
%macro output_histogram(type=, weight=);
%isdata(dataset=repdata.Figure&figurenum.&tableletter.);
%if %eval(&nobs=0) %then %do;
data repdata.Figure&figurenum.&tableletter.;
set histogram_&i. (where=(runid="&runid." and order="&loopcount." and subgroup="&subgroup." and subgroupcat="&subgroupcat."));
proc sgplot data=histogram_&i. (where=(runid="&runid." and order="&loopcount." and subgroup="&subgroup." and subgroupcat="&subgroupcat."));
histogram bin_eoi / freq = _eoi transparency=0.8 fillattrs=(color=blue) binstart = 0 binwidth = 0.025;
histogram bin_ref / freq =_ref transparency=0.8 fillattrs=(color=red) binstart = 0 binwidth = 0.025;
keylegend / location=outside position=bottom noborder valueattrs=(size=&fontsize. family=&font.);
xaxis label = "PS" labelattrs=(size=&fontsize. family=&font. color=gray) valueattrs=(size=&fontsize. family=&font. color=gray) values=(0 to 1 by .2) offsetmax = .02;
yaxis display=(noline) label="Percent" labelattrs=(size=&fontsize. family=&font. color=gray) valueattrs=(size=&fontsize. family=&font. color=gray);
where type = "&type." and weight="&weight." and dp = "&maskeddpid." and lowcase(analysisgrp) = "&analysisgrp.";
options orientation=portrait;
%do i = %eval(&look_start) %to %eval(&look_end); /*loop through periods*/
%do loopcount = 1 %to &numl2comparisons.;
set l2comparisonfile(where=(order=&loopcount.));
call symputx('runid', runid);
call symputx('analysisgrp', analysisgrp);
call symputx('OutputPSDistribution', OutputPSDistribution);