****************************************************************************************************
****************************************************************************************************
* PROGRAM: l2_psdistribution_createdata.sas
* Created (mm/dd/yyyy): 03/17/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: The macro creates both aggregated and DP specific PS distribution datasets
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro l2_psdistribution_createdata;
%do loopcount = 1 %to &numl2comparisons.;
/*Initialize macro variables for the analysisgrp loop*/
%let OutputPSDistribution = ;
/*set parameters from l2comparisonfile for this loop*/
set l2comparisonfile(where=(order=&loopcount.));
call symputx('runid', runid);
call symputx('analysisgrp', analysisgrp);
call symputx('OutputPSDistribution', OutputPSDistribution);
%if &OutputPSDistribution.=Y %then %do;
/* only psmatchfile, stratificationfile, and iptwfile have histogram */
select strip(file) into: psfile
from pscs_masterinputs (where = (missing(subgroup)))
where analysisgrp = "&analysisgrp.";
%put now computing PS distributions for &analysisgrp.;
%if &psfile. = psmatchfile | &psfile. = stratificationfile | &psfile. = iptwfile %then %do;
set pscs_masterinputs (where=(lowcase(analysisgrp)="&analysisgrp." and missing(subgroup)));
call symputx("psestimategrp", lowcase(psestimategrp));
%if &psfile. = psmatchfile %then %do;
call symputx('RATIO',upcase(ratio)) ;
%if &psfile. = stratificationfile %then %do;
call symputx("strataweight",strataweight);