****************************************************************************************************
****************************************************************************************************
* PROGRAM: codedistribution_createdata.sas
* Created (mm/dd/yyyy): 04/16/2021
*--------------------------------------------------------------------------------------------------
* PURPOSE: The macro creates aggregated code distribution dataset and process code descriptions
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro codedistribution_createdata;
select count(*) into :numgroupscodedist trimmed
%do loopcount = 1 %to &numgroupscodedist.;
/* set parameters for this loop */
call symputx('runid', runid);
call symputx('group', group);
call symputx('order', order);
if index(upcase(codedist), "EXP") > 0 then call symputx('codedistexp', 'Y');
if index(upcase(codedist), "HOI") > 0 then call symputx('codedisthoi', 'Y');
/* Aggregate results and keep only relevant distindextype */
proc means data=agg_distindex (where=(lowcase(group)="&group." and runid="&runid.")) noprint nway missing;
class group runid distindextype distindexlist dpidsiteid;
output out=_agg_distindex(drop=_:) sum=;
%if &codedistexp. ne Y %then %do;
if lowcase(distindextype)="exp" then delete;
%if &codedisthoi. ne Y %then %do;