Clinwright Public work of Clinwright examples · free Start free

14-1.03

Summary of Number of Subjects By Site

Made 2026-10-17 from uploaded data.

CDISCPILOT01

Table 14-1.03

Summary of Number of Subjects By Site

All Subjects Analysis Set

Placebo (N=86)Xanomeline Low Dose (N=84)Xanomeline High Dose (N=84)Total (N=254)
ITTEffComITTEffComITTEffComITTEffCom
701
7011414111313514147414123
703
70365465165218157
704
70499587388025248
705
70553255364116126
708
708997882852252211
709
709775762773212010
710
7101186101021085312613
713
713333332322987
716
716887883883242413
718
71844355144113135
900
702000110000110
706111110110331
707111110000221
711111110210431
714222221221664
715322331220873
717220222333775
TOTAL867960848128847430254234118

Note: ITT: Number of subjects in the ITT population, Eff: Number of subjects in the Efficacy population; Com: Number of subjects completing Week 24.

Program: t-14-1-03.sas

Program t-14-1-03.sas

Version 1, written from Clinwright's patterns, 2026-10-17, checks passed.

/*==== 00-header ====*/
/*----------------------------------------------------------------------------
  Output  : Table 14-1.03 / Summary of Number of Subjects By Site / All Subjects Analysis Set
  Program : t-14-1-03.sas   Reporting effort : CSR
  ADaM    : /work/adam (ADSL, ADADAS, ADCIBC, ADLBC, ADLBH, ADNPIX, ADTTE, ADVS, ADAE, ADCM, ADMH, ADEX)
  The header and the report step follow from the shell. The sections between
  them make WORK.FINAL, one record per row of the table, in order:
    _page     the page (1 unless the output is paged); _pagelbl its heading or empty
    _ord      the row's order; _indent the label's indentation (0 = flush left)
    _rowid    the uuid of the shell row it shows (WORK._SHELL); one shell row may
              have several (a category per value); a blank row's is blank-<n>
    _kind     label | stat | blank
    rowlabel  the row's label, as text
    col1      ITT
    col2      Eff
    col3      Com
    col4      ITT
    col5      Eff
    col6      Com
    col7      ITT
    col8      Eff
    col9      Com
    col10     ITT
    col11     Eff
    col12     Com
  and set the big N of the column headers:
    &_bign1_3  Placebo|(N=xx)
    &_bign4_6  Xanomeline Low Dose|(N=xx)
    &_bign7_9  Xanomeline High Dose|(N=xx)
    &_bign10_12 Total|(N=xx)
  /work/_lib/clinwright.sas has %ls_bign, %ls_count, %ls_stats, %ls_npct, %ls_num.
----------------------------------------------------------------------------*/
libname adam "/work/adam" access=readonly;
%include "/work/_lib/clinwright.sas";
%ls_setup;

/* The shell's rows, in order, with each column's value pattern (_xx1-_xx12). */
data work._shell;
  length _page 8 _pagelbl $200 _ord 8 _indent 8 _rowid $36 _kind $5 _var $32 rowlabel $200 _xx1 $40 _xx2 $40 _xx3 $40 _xx4 $40 _xx5 $40 _xx6 $40 _xx7 $40 _xx8 $40 _xx9 $40 _xx10 $40 _xx11 $40 _xx12 $40;
  _page = 1; _pagelbl = '';
  _ord=1; _indent=0; _rowid='2ddf90a3-27b8-42c6-8373-74c046370f82'; _kind='label'; _var=''; rowlabel='[Pooled Id]'; _xx1=''; _xx2=''; _xx3=''; _xx4=''; _xx5=''; _xx6=''; _xx7=''; _xx8=''; _xx9=''; _xx10=''; _xx11=''; _xx12=''; output;
  _ord=2; _indent=1; _rowid='44c81d32-0ea9-44ec-ba69-787f38c916c0'; _kind='stat'; _var=''; rowlabel='[Site Id]'; _xx1='xx'; _xx2='xx'; _xx3='xx'; _xx4='xx'; _xx5='xx'; _xx6='xx'; _xx7='xx'; _xx8='xx'; _xx9='xx'; _xx10='xx'; _xx11='xx'; _xx12='xx'; output;
  _ord=3; _indent=0; _rowid='blank-3'; _kind='blank'; _var=''; rowlabel=''; _xx1=''; _xx2=''; _xx3=''; _xx4=''; _xx5=''; _xx6=''; _xx7=''; _xx8=''; _xx9=''; _xx10=''; _xx11=''; _xx12=''; output;
  _ord=4; _indent=0; _rowid='0e5877d3-242a-4476-8bc8-df3b7f743cc8'; _kind='stat'; _var=''; rowlabel='TOTAL'; _xx1='xx'; _xx2='xx'; _xx3='xx'; _xx4='xx'; _xx5='xx'; _xx6='xx'; _xx7='xx'; _xx8='xx'; _xx9='xx'; _xx10='xx'; _xx11='xx'; _xx12='xx'; output;
run;

/*==== 10-data ====*/
/* Made from the output's analysis: the subjects of ADSL, by TRT01P. */
data work._an;
  set adam.adsl;
  if trt01p in ('Placebo') and ittfl = 'Y' then do; _col = 1; output; end;
  if trt01p in ('Placebo') and efffl = 'Y' then do; _col = 2; output; end;
  if trt01p in ('Placebo') and comp24fl = 'Y' then do; _col = 3; output; end;
  if trt01p in ('Xanomeline Low Dose') and ittfl = 'Y' then do; _col = 4; output; end;
  if trt01p in ('Xanomeline Low Dose') and efffl = 'Y' then do; _col = 5; output; end;
  if trt01p in ('Xanomeline Low Dose') and comp24fl = 'Y' then do; _col = 6; output; end;
  if trt01p in ('Xanomeline High Dose') and ittfl = 'Y' then do; _col = 7; output; end;
  if trt01p in ('Xanomeline High Dose') and efffl = 'Y' then do; _col = 8; output; end;
  if trt01p in ('Xanomeline High Dose') and comp24fl = 'Y' then do; _col = 9; output; end;
  if ittfl = 'Y' then do; _col = 10; output; end;
  if efffl = 'Y' then do; _col = 11; output; end;
  if comp24fl = 'Y' then do; _col = 12; output; end;
run;
data work._popc; set work._an(keep=usubjid _col); run;
data work._cols; do _col = 1 to 12; output; end; run;
%ls_bign(data=work._popc, trt=_col, values=1|2|3|4|5|6|7|8|9|10|11|12|1 2 3|4 5 6|7 8 9|10 11 12, names=_lsn1 _lsn2 _lsn3 _lsn4 _lsn5 _lsn6 _lsn7 _lsn8 _lsn9 _lsn10 _lsn11 _lsn12 _bign1_3 _bign4_6 _bign7_9 _bign10_12);

/* Subjects and records per column. */
proc sort data=work._an(keep=usubjid _col) out=work._u; by _col usubjid; run;
data work._c;
  set work._u;
  by _col usubjid;
  retain _n _e;
  if first._col then do; _n = 0; _e = 0; end;
  _e = _e + 1;
  if first.usubjid then _n = _n + 1;
  if last._col then output;
  keep _col _n _e;
run;
proc transpose data=work._c out=work._tn(drop=_name_) prefix=_n; id _col; var _n; run;
proc transpose data=work._c out=work._te(drop=_name_) prefix=_e; id _col; var _e; run;
data work._z; _z = 1; run;
data work._g1;
  merge work._z work._tn work._te;
  array _nn{12} _n1-_n12;
  array _ee{12} _e1-_e12;
  do _i = 1 to 12; _nn{_i} = sum(_nn{_i}, 0); _ee{_i} = sum(_ee{_i}, 0); end;
  _tot = _n10;
  drop _i _z;
run;
/* Per value of sitegr1: subjects and records per column. */
proc sort data=work._an(keep=usubjid _col sitegr1 where=(not missing(sitegr1))) out=work._u; by sitegr1 _col usubjid; run;
data work._c;
  set work._u;
  by sitegr1 _col usubjid;
  retain _n _e;
  if first._col then do; _n = 0; _e = 0; end;
  _e = _e + 1;
  if first.usubjid then _n = _n + 1;
  if last._col then output;
  keep sitegr1 _col _n _e;
run;
proc transpose data=work._c out=work._tn(drop=_name_) prefix=_n; by sitegr1; id _col; var _n; run;
proc transpose data=work._c out=work._te(drop=_name_) prefix=_e; by sitegr1; id _col; var _e; run;
data work._g0;
  merge work._tn work._te; by sitegr1;
  array _nn{12} _n1-_n12;
  array _ee{12} _e1-_e12;
  do _i = 1 to 12; _nn{_i} = sum(_nn{_i}, 0); _ee{_i} = sum(_ee{_i}, 0); end;
  _tot = _n10;
  drop _i;
run;
proc sort data=work._g0; by  sitegr1; run;
data work._g0;
  set work._g0;
  _o1 = _n_;
run;
/* [Pooled Id] of SITEGR1. */
data work._f; set work._g0; do _col = 1 to 12; output; end; run;
proc sort data=work._f; by sitegr1 _col; run;
data work._k1;
  length _rowid $36 _label _pagelbl $200 _v $200;
  set work._f;
  array _nn{12} _n1-_n12;
  array _ee{12} _e1-_e12;
  _rowid = '2ddf90a3-27b8-42c6-8373-74c046370f82';
  _page = 1;
  _pagelbl = '';
  _k0 = 1;
  _k1 = _o1; _k2 = 0;
  _k3 = 0; _k4 = 0;
  _label = strip(sitegr1);
  _v = '';
  keep _rowid _label _page _pagelbl _k0 _k1 _k2 _k3 _k4 _col _v;
run;
/* Per value of sitegr1 and siteid: subjects and records per column. */
proc sort data=work._an(keep=usubjid _col sitegr1 siteid where=(not missing(sitegr1) and not missing(siteid))) out=work._u; by sitegr1 siteid _col usubjid; run;
data work._c;
  set work._u;
  by sitegr1 siteid _col usubjid;
  retain _n _e;
  if first._col then do; _n = 0; _e = 0; end;
  _e = _e + 1;
  if first.usubjid then _n = _n + 1;
  if last._col then output;
  keep sitegr1 siteid _col _n _e;
run;
proc transpose data=work._c out=work._tn(drop=_name_) prefix=_n; by sitegr1 siteid; id _col; var _n; run;
proc transpose data=work._c out=work._te(drop=_name_) prefix=_e; by sitegr1 siteid; id _col; var _e; run;
data work._g2;
  merge work._tn work._te; by sitegr1 siteid;
  array _nn{12} _n1-_n12;
  array _ee{12} _e1-_e12;
  do _i = 1 to 12; _nn{_i} = sum(_nn{_i}, 0); _ee{_i} = sum(_ee{_i}, 0); end;
  _tot = _n10;
  drop _i;
run;
proc sort data=work._g2; by sitegr1 siteid; run;
data work._g2;
  set work._g2;
  by sitegr1;
  retain _r;
  if first.sitegr1 then _r = 0;
  _r = _r + 1;
  _o2 = _r;
  drop _r;
run;
proc sort data=work._g2; by sitegr1; run;
proc sort data=work._g0(keep=sitegr1 _o1) out=work._gp; by sitegr1; run;
data work._g2; merge work._g2(in=_in) work._gp; by sitegr1; if _in; run;
/* [Site Id]: count of SITEID. */
data work._f; set work._g2; do _col = 1 to 12; output; end; run;
proc sort data=work._f; by sitegr1 siteid _col; run;
data work._k2;
  length _rowid $36 _label _pagelbl $200 _v $200;
  set work._f;
  array _nn{12} _n1-_n12;
  array _ee{12} _e1-_e12;
  _rowid = '44c81d32-0ea9-44ec-ba69-787f38c916c0';
  _page = 1;
  _pagelbl = '';
  _k0 = 1;
  _k1 = _o1; _k2 = 2;
  _k3 = _o2; _k4 = 0;
  _label = strip(siteid);
  _v = strip(ifc(missing(_nn{_col}), '-', %ls_num(_nn{_col}, 0)));
  keep _rowid _label _page _pagelbl _k0 _k1 _k2 _k3 _k4 _col _v;
run;
/* . */
data work._f; set work._g0; do _col = 1 to 12; output; end; run;
proc sort data=work._f; by sitegr1 _col; run;
data work._k3;
  length _rowid $36 _label _pagelbl $200 _v $200;
  set work._f;
  array _nn{12} _n1-_n12;
  array _ee{12} _e1-_e12;
  _rowid = 'blank-3';
  _page = 1;
  _pagelbl = '';
  _k0 = 1;
  _k1 = _o1; _k2 = 3;
  _k3 = 0; _k4 = 0;
  _label = '';
  _v = '';
  keep _rowid _label _page _pagelbl _k0 _k1 _k2 _k3 _k4 _col _v;
run;
/* TOTAL: any. */
data work._f; set work._g1; do _col = 1 to 12; output; end; run;
data work._k4;
  length _rowid $36 _label _pagelbl $200 _v $200;
  set work._f;
  array _nn{12} _n1-_n12;
  array _ee{12} _e1-_e12;
  _rowid = '0e5877d3-242a-4476-8bc8-df3b7f743cc8';
  _page = 1;
  _pagelbl = '';
  _k0 = 4;
  _k1 = 0; _k2 = 0;
  _k3 = 0; _k4 = 0;
  _label = '';
  _v = strip(ifc(missing(_nn{_col}), '-', %ls_num(_nn{_col}, 0)));
  keep _rowid _label _page _pagelbl _k0 _k1 _k2 _k3 _k4 _col _v;
run;

data work._cells; set work._k1 work._k2 work._k3 work._k4; run;
proc sort data=work._cells; by _page _pagelbl _k0 _k1 _k2 _k3 _k4 _rowid _label _col; run;
proc transpose data=work._cells out=work._wide(drop=_name_) prefix=col;
  by _page _pagelbl _k0 _k1 _k2 _k3 _k4 _rowid _label;
  id _col;
  var _v;
run;
proc sort data=work._wide; by _rowid; run;
proc sort data=work._shell(drop=_page _pagelbl) out=work._rows; by _rowid; run;
data work._inst;
  merge work._wide(in=_w) work._rows(in=_s);
  by _rowid;
  if _w and _s;
  if _label ne '' then rowlabel = _label;
run;
data work._fixed;
  set work._shell;
  if _rowid not in ('2ddf90a3-27b8-42c6-8373-74c046370f82' '44c81d32-0ea9-44ec-ba69-787f38c916c0' 'blank-3' '0e5877d3-242a-4476-8bc8-df3b7f743cc8');
  _k0 = _ord; _k1 = 0; _k2 = 0; _k3 = 0; _k4 = 0;
run;
data work.final;
  length col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 $200 _pagelbl $200;
  set work._inst work._fixed;
run;
proc sort data=work.final; by _page _k0 _k1 _k2 _k3 _k4; run;
data work.final;
  set work.final;
  _ord = _n_;
  keep _page _pagelbl _ord _indent _rowid _kind rowlabel col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12;
run;

/*==== 90-report ====*/
/* 90-report: from the shell; the titles, columns, headers and footnotes are not changed here. */
%ls_need(_bign1_3 _bign4_6 _bign7_9 _bign10_12);
%ls_final_check(columns=_page _pagelbl _ord _indent _rowid _kind rowlabel col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12);
proc sort data=work.final out=work._report; by _page _ord; run;
data work._report;
  set work._report;
  /* Two spaces per step of indentation: the label column keeps leading spaces (asis=on). */
  if _indent > 0 then rowlabel = repeat(' ', 2 * _indent - 1) || rowlabel;
run;
%let _lspaged = 0;
proc sql noprint; select count(*) into :_lspaged trimmed from work._report where _pagelbl ne ''; quit;

options orientation=landscape;
ods listing close;
ods rtf file="/work/out/t-14-1-03.rtf" style=journal;
title1 j=l "CDISCPILOT01" j=r "Page ~{thispage} of ~{lastpage}";
title2 j=c "Table 14-1.03";
title3 j=c "Summary of Number of Subjects By Site";
title4 j=c "All Subjects Analysis Set";
footnote1 j=l "Note: ITT: Number of subjects in the ITT population, Eff: Number of subjects in the Efficacy population; Com: Number of subjects completing Week 24.";
footnote2 j=l "Program: t-14-1-03.sas";
%macro _ls_report;
proc report data=work._report nowd split='|' missing style(report)={width=100%};
  column _page _pagelbl _ord _indent _kind rowlabel ("Placebo|(N=&_bign1_3.)" col1 col2 col3) ("Xanomeline Low Dose|(N=&_bign4_6.)" col4 col5 col6) ("Xanomeline High Dose|(N=&_bign7_9.)" col7 col8 col9) ("Total|(N=&_bign10_12.)" col10 col11 col12);
  define _page / order order=internal noprint;
  define _pagelbl / order noprint;
  define _ord / order order=internal noprint;
  define _indent / display noprint;
  define _kind / display noprint;
  define rowlabel / display "" style(column)={cellwidth=40% asis=on} style(header)={just=l};
  define col1 / display "ITT" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col2 / display "Eff" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col3 / display "Com" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col4 / display "ITT" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col5 / display "Eff" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col6 / display "Com" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col7 / display "ITT" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col8 / display "Eff" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col9 / display "Com" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col10 / display "ITT" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col11 / display "Eff" style(column)={cellwidth=5% just=c} style(header)={just=c};
  define col12 / display "Com" style(column)={cellwidth=5% just=c} style(header)={just=c};
  %if &_lspaged > 0 %then %do;
  compute before _pagelbl / style={just=l};
    line _pagelbl $200.;
  endcomp;
  %end;
  break after _page / page;
run;
%mend _ls_report;
%_ls_report;
ods rtf close;
ods listing;
%ls_final_export;