****************************************************************************************************
****************************************************************************************************
* PROGRAM: baseline_profile_output.sas
* Created (mm/dd/yyyy): 04/29/2021
*--------------------------------------------------------------------------------------------------
* Transform and output covariate profile tables
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
*--------------------------------------------------------------------------------------------------
* Version Date Initials Comment (reference external documentation when available)
* ------- -------- -------- ----------------------------------------------------------------
***************************************************************************************************;
%macro baseline_profile_output;
/* Reset table letter at top of dataset loop */
%do periodid = %eval(&look_start.) %to %eval(&look_end.);
select 'order='||strip(put(order,8.))||' and runid='||quote(strip(runid))||' and group='||quote(strip(group))||' and cohort='||quote(strip(cohort))
into :whereexpr separated by '@'
from (select order, runid, group, case when(cohort is missing) then 'all' else cohort end as cohort
where not missing(profilecovarstoinclude))
%do wherenum = 1 %to %sysfunc(countw(&whereexpr, @));
%let where = %scan(&whereexpr,&wherenum, @);
data _temp_agg_order_profile;
set aggregate_profile(where=(periodid=&periodid and &where));
if cohort = 'mi' then group2=scan(group,1,'_');
if cohort = 'switch' then switchlabel=' ';
call symputx('runid',runid);
%let profileswitches = 0;