|
| 1 | +/*****************************************************************************\ |
| 2 | +* ____ _ |
| 3 | +* | _ \ ___ _ __ ___ (_)_ __ ___ |
| 4 | +* | | | |/ _ \| '_ ` _ \| | '_ \ / _ \ |
| 5 | +* | |_| | (_) | | | | | | | | | | (_) | |
| 6 | +* |____/ \___/|_| |_| |_|_|_| |_|\___/ |
| 7 | +* ____________________________________________________________________________ |
| 8 | +* Sponsor : Domino |
| 9 | +* Study : CDISC01 |
| 10 | +* Program : qc_t_pop.sas |
| 11 | +* Purpose : Create the QC Summary of Populations Table |
| 12 | +* ____________________________________________________________________________ |
| 13 | +* DESCRIPTION |
| 14 | +* |
| 15 | +* Input files: ADaM.ADSL |
| 16 | +* |
| 17 | +* Output files: qc_t_pop. |
| 18 | +* t_pop.sas7bdat |
| 19 | +* |
| 20 | +* Macros: None vt |
| 21 | +* |
| 22 | +* Assumptions: Demo only - Second comment 20240311 |
| 23 | +* |
| 24 | +* ____________________________________________________________________________ |
| 25 | +* PROGRAM HISTORY |
| 26 | +* 10MAY2023 | Megan Harries | Original |
| 27 | +* 08DEC2023 | Petter Olsson | Demo Comment |
| 28 | +* ---------------------------------------------------------------------------- |
| 29 | +\*****************************************************************************/ |
| 30 | + |
| 31 | +*********; |
| 32 | +** Setup environment including libraries for this reporting effort; |
| 33 | +%include "/mnt/code/domino.sas"; |
| 34 | +*********; |
| 35 | + |
| 36 | +ods path(prepend) work.templat(update); |
| 37 | + |
| 38 | +*Set the template for the output; |
| 39 | +proc template; |
| 40 | + define style newstyle; |
| 41 | + |
| 42 | + class Table / |
| 43 | + Rules = Groups |
| 44 | + Frame = void; |
| 45 | + |
| 46 | + style header |
| 47 | + / just = c |
| 48 | + fontweight = medium; |
| 49 | + |
| 50 | + replace Body from Document / |
| 51 | + bottommargin = 1.54cm |
| 52 | + topmargin = 2.54cm |
| 53 | + rightmargin = 2.54cm |
| 54 | + leftmargin = 2.54cm; |
| 55 | + |
| 56 | + replace fonts / |
| 57 | + 'TitleFont2' = ("Courier New",9pt) |
| 58 | + 'TitleFont' = ("Courier New",9pt/*,Bold*/) /* titles */ |
| 59 | + 'StrongFont' = ("Courier New",9pt/*,Bold*/) |
| 60 | + 'EmphasisFont' = ("Courier New",9pt,Italic) |
| 61 | + 'FixedEmphasisFont' = ("Courier New, Courier",9pt,Italic) |
| 62 | + 'FixedStrongFont' = ("Courier New, Courier",9pt/*,Bold*/) |
| 63 | + 'FixedHeadingFont' = ("Courier New, Courier",9pt/*,Bold*/) |
| 64 | + 'BatchFixedFont' = ("SAS Monospace, Courier New, Courier",9pt) |
| 65 | + 'FixedFont' = ("Courier New, Courier",9pt) |
| 66 | + 'headingEmphasisFont' = ("Courier New",9pt,Bold Italic) |
| 67 | + 'headingFont' = ("Courier New",9pt/*,Bold*/) /* header block */ |
| 68 | + 'docFont' = ("Courier New",9pt); /* table cells */ |
| 69 | + |
| 70 | + replace color_list |
| 71 | + "Colors used in the default style" / |
| 72 | + 'link' = blue |
| 73 | + 'bgH' = white /* header background */ |
| 74 | + 'fg' = black |
| 75 | + 'bg' = _undef_; |
| 76 | +end; |
| 77 | +run ; |
| 78 | + |
| 79 | +options orientation = landscape nonumber nodate nobyline; |
| 80 | + |
| 81 | +** adsl and include required variables for table; |
| 82 | +data adsl_all (rename = (actarm = trta)); |
| 83 | + length trtan agen sexn 8.; |
| 84 | + set adam.adsl; |
| 85 | + |
| 86 | + if actarm = "Placebo" then trtan = 1; |
| 87 | + else if actarm = "Xanomeline Low Dose" then trtan = 2; |
| 88 | + else if actarm = "Xanomeline High Dose" then trtan = 3; |
| 89 | + |
| 90 | + if age < 60 then agen = 1; |
| 91 | + else if 60 <= age < 65 then agen = 2; |
| 92 | + else if 65 <= age < 70 then agen = 3; |
| 93 | + else if 70 <= age < 75 then agen = 4; |
| 94 | + else if 75 <= age < 80 then agen = 5; |
| 95 | + else if 80 <= age then agen = 6; |
| 96 | + |
| 97 | + if sex = 'M' then sexn = 1; |
| 98 | + if sex = 'F' then sexn = 2; |
| 99 | +run; |
| 100 | + |
| 101 | +** observations in the population, and the parameters specified in SAP; |
| 102 | +data adsl (keep = usubjid trta trtan age agen sex sexn); |
| 103 | + set adsl_all(where = (trtan ne .)); |
| 104 | +run; |
| 105 | + |
| 106 | +** create macro for counting number of placebo participants; |
| 107 | +proc sql noprint; |
| 108 | + select count(distinct usubjid) |
| 109 | + into :placebo_n |
| 110 | + from adsl(where = (trta = "Placebo")); |
| 111 | +quit; |
| 112 | + |
| 113 | +** create macro for counting number of Xanomeline Low Dose participants; |
| 114 | +proc sql noprint; |
| 115 | + select count(distinct usubjid) |
| 116 | + into :low_dose_n |
| 117 | + from adsl(where = (trta = "Xanomeline Low Dose")); |
| 118 | +quit; |
| 119 | + |
| 120 | +** create macro for counting number of Xanomeline High Dose participants; |
| 121 | +proc sql noprint; |
| 122 | + select count(distinct usubjid) |
| 123 | + into :high_dose_n |
| 124 | + from adsl(where = (trta = "Xanomeline High Dose")); |
| 125 | +quit; |
| 126 | + |
| 127 | +** create macro for each variable results; |
| 128 | +** calculate number of unique subjects with post-baseline results; |
| 129 | +proc sql; |
| 130 | + create table total_age as |
| 131 | + select trta, count(distinct usubjid) as count_age |
| 132 | + from adsl |
| 133 | + group by trta; |
| 134 | +quit; |
| 135 | + |
| 136 | +** calculate number of unique subjects for each age group; |
| 137 | +%macro age_data(agen = ); |
| 138 | + data age&agen.; |
| 139 | + set adsl; |
| 140 | + where agen = &agen.; |
| 141 | + run; |
| 142 | + |
| 143 | + proc sql; |
| 144 | + create table total_age&agen. as |
| 145 | + select trta, count(distinct usubjid) as n&agen. |
| 146 | + from age&agen. |
| 147 | + group by trta; |
| 148 | + quit; |
| 149 | +%mend age_data; |
| 150 | + |
| 151 | +%age_data(agen = 1); |
| 152 | +%age_data(agen = 2); |
| 153 | +%age_data(agen = 3); |
| 154 | +%age_data(agen = 4); |
| 155 | +%age_data(agen = 5); |
| 156 | +%age_data(agen = 6); |
| 157 | + |
| 158 | +** merge the counts and calculate percentages; |
| 159 | +data results; |
| 160 | + merge total_age total_age1 total_age2 total_age3 total_age4 total_age5 total_age6; |
| 161 | + by trta; |
| 162 | + if n1 ne . then p1 = cats("(", put(100*n1/count_age, 6.1), ")"); |
| 163 | + if n2 ne . then p2 = cats("(", put(100*n2/count_age, 6.1), ")"); |
| 164 | + if n3 ne . then p3 = cats("(", put(100*n3/count_age, 6.1), ")"); |
| 165 | + if n4 ne . then p4 = cats("(", put(100*n4/count_age, 6.1), ")"); |
| 166 | + if n5 ne . then p5 = cats("(", put(100*n5/count_age, 6.1), ")"); |
| 167 | + if n6 ne . then p6 = cats("(", put(100*n6/count_age, 6.1), ")"); |
| 168 | +run; |
| 169 | + |
| 170 | +** concatenate results for any parameter data; |
| 171 | +data results_c; |
| 172 | + length results1 results2 results3 results4 results5 results6 $32; |
| 173 | + set results; |
| 174 | + |
| 175 | + ** convert post baseline count to character; |
| 176 | + count_age_c = ""; |
| 177 | + |
| 178 | + ** if 100% then no decimal places; |
| 179 | + if p1 = "(100.0)" then p1 = "(100)"; |
| 180 | + if p2 = "(100.0)" then p2 = "(100)"; |
| 181 | + if p3 = "(100.0)" then p3 = "(100)"; |
| 182 | + if p4 = "(100.0)" then p4 = "(100)"; |
| 183 | + if p5 = "(100.0)" then p5 = "(100)"; |
| 184 | + if p6 = "(100.0)" then p6 = "(100)"; |
| 185 | + |
| 186 | + |
| 187 | + ** if 0% then only n = 0 is displayed, no event or percentage; |
| 188 | + ** concatenate n and p; |
| 189 | + if p1 = " " then results1 = "0"; |
| 190 | + else results1 = catx(" ", put(n1, 8.), p1); |
| 191 | + if p2 = " " then results2 = "0"; |
| 192 | + else results2 = catx(" ", put(n2, 8.), p2); |
| 193 | + if p3 = " " then results3 = "0"; |
| 194 | + else results3 = catx(" ", put(n3, 8.), p3); |
| 195 | + if p4 = " " then results4 = "0"; |
| 196 | + else results4 = catx(" ", put(n4, 8.), p4); |
| 197 | + if p5 = " " then results5 = "0"; |
| 198 | + else results5 = catx(" ", put(n5, 8.), p5); |
| 199 | + if p6 = " " then results6 = "0"; |
| 200 | + else results6 = catx(" ", put(n6, 8.), p6); |
| 201 | +run; |
| 202 | + |
| 203 | +** transpose any results dataset; |
| 204 | +options validvarname=v7; |
| 205 | +proc transpose data = results_c out = results_t name = agegroup; |
| 206 | + id trta; |
| 207 | + var count_age_c results1 results2 results3 results4 results5 results6; |
| 208 | +run; |
| 209 | + |
| 210 | + |
| 211 | +** add parameter identifier and order variable; |
| 212 | +data order_results(rename = (Xanomeline_Low_Dose = Low_Dose Xanomeline_High_Dose = High_Dose)); |
| 213 | + length order1 8. ageresults $50 stat $8; |
| 214 | + set results_t; |
| 215 | + if agegroup = "count_age_c" then do; |
| 216 | + order1 = 1; |
| 217 | + ageresults = ""; |
| 218 | + stat = ""; |
| 219 | + end; |
| 220 | + else do; |
| 221 | + order1 = input(substr(agegroup, 8), 8.)+1; |
| 222 | + stat = "n (%)"; |
| 223 | + end; |
| 224 | + |
| 225 | + if agegroup = "results1" then ageresults = "Less than 60 years old"; |
| 226 | + else if agegroup = "results2" then ageresults = "60 years old <= age < 65 years old"; |
| 227 | + else if agegroup = "results3" then ageresults = "65 years old <= age < 70 years old"; |
| 228 | + else if agegroup = "results4" then ageresults = "70 years old <= age < 75 years old"; |
| 229 | + else if agegroup = "results5" then ageresults = "75 years old <= age < 80 years old"; |
| 230 | + else if agegroup = "results6" then ageresults = "80 years and older"; |
| 231 | +run; |
| 232 | + |
| 233 | +** create the table output; |
| 234 | + |
| 235 | +ods pdf file = "/mnt/artifacts/TFL_QC/qc_t_pop.pdf" |
| 236 | + style = newstyle; |
| 237 | + |
| 238 | +ods noproctitle; |
| 239 | +ods escapechar = "^"; |
| 240 | + |
| 241 | +** add titles to output; |
| 242 | +title1 justify = left "Domino" justify = right "Page ^{thispage} of ^{lastpage}"; |
| 243 | +title2 "Table 14.3.4.1"; |
| 244 | +title3 "Summary of Age for each Treatment"; |
| 245 | +title4 "Analysis Set"; |
| 246 | + |
| 247 | +** justify contents to decimal places; |
| 248 | +** if you want TFL to also be written to Dataset. proc report data = order_results headline split = "*" style(report) = {width = 100% cellpadding = 3} out = tflqc.t_pop; |
| 249 | +proc report data = order_results headline split = "*" style(report) = {width = 100% cellpadding = 3}; |
| 250 | + column (order1 ageresults stat placebo low_dose high_dose); |
| 251 | + |
| 252 | + ** order variables; |
| 253 | + define order1 / order noprint; |
| 254 | + |
| 255 | + define ageresults / "*Age Group" style(column) = {just = l asis = on width = 30%} style(header) = {just = l asis = on}; |
| 256 | + define stat / "*Statistic" style(column) = {just = l width = 10%}; |
| 257 | + define placebo / "Placebo* (N=%cmpres(&placebo_n))" style(column) = {just = d width = 18%}; |
| 258 | + define low_dose / "Xanomeline Low Dose* (N=%cmpres(&low_dose_n))" style(column) = {just = d width = 20%}; |
| 259 | + define high_dose / "Xanomeline High Dose* (N=%cmpres(&high_dose_n))" style(column) = {just = d width = 20%}; |
| 260 | + |
| 261 | + ** add footnotes describing the critical codes; |
| 262 | + footnote1 justify = left "Note: n = number of unique subjects in age group."; |
| 263 | + footnote2 justify = left "Note: percentages are based on the number of patients for each treatment."; |
| 264 | + footnote3 justify = left "Dataset(s): ADSL; Program: qc_t_pop.sas; Output: qc_t_pop.pdf; Generated on: &sysdate9 &systime"; |
| 265 | +run; |
| 266 | + |
| 267 | +ods pdf close; |
| 268 | + |
| 269 | + |
0 commit comments