Answers, Part III
Every answer below was checked by running the code on SAS OnDemand with the pilot data.
Chapter 13: Tables
Section titled “Chapter 13: Tables”Exercise 13-1. PROC FREQ writes only the combinations that exist: 7 rows, and for placebo only two (BLACK OR AFRICAN AMERICAN 8, WHITE 78). American Indian has a row only for the high dose, so after the transpose the placebo and low dose cells are blank, not 0. Add SPARSE to the TABLES statement (TABLES trt01an * race / SPARSE OUT=race_cnt;): the output then has a row with COUNT = 0 for placebo and for the low dose. The race lines are WHITE 78 (90.7), 78 (92.9), 74 (88.1); BLACK OR AFRICAN AMERICAN 8 (9.3), 6 (7.1), 9 (10.7); AMERICAN INDIAN OR ALASKA NATIVE 0, 0, 1 (1.2).
Exercise 13-2. All four. The big N gets a fourth column (254 subjects). Compute needs every record twice, once with its own treatment and once as “Total”, for example DATA adsl2; SET refadm.adsl; OUTPUT; trt01an = 99; OUTPUT; RUN;. Arrange gets one more column from the transpose, and print one more DEFINE.
Exercise 13-3.
PROC SQL; SELECT trtan, COUNT(DISTINCT usubjid) AS subjects FROM refadm.adae WHERE saffl = "Y" AND trtemfl = "Y" AND aeser = "Y" GROUP BY trtan;QUIT;1 subject on the low dose and 2 on the high dose. Placebo has no row: GROUP BY makes a line only for groups that exist in the data. In a table that line must say 0, which is why 13_2 builds the grid in Step 040.
Exercise 13-4. GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONS (108 subjects), SKIN AND SUBCUTANEOUS TISSUE DISORDERS (99), NERVOUS SYSTEM DISORDERS (53). Add the total of each SOC to the rows and number the SOCs in that order; the number becomes the first ORDER NOPRINT column, because PROC REPORT would sort aebodsys alphabetically again:
PROC SQL; CREATE TABLE soc_order AS SELECT aebodsys, SUM(n) AS soc_total FROM ae_soc GROUP BY aebodsys; CREATE TABLE ae_text2 AS SELECT a.*, COALESCE(o.soc_total, 9999) AS soc_total FROM ae_text AS a LEFT JOIN soc_order AS o ON a.aebodsys = o.aebodsys;QUIT;PROC SORT DATA=ae_text2; BY DESCENDING soc_total aebodsys level aedecod trtan; RUN;DATA ae_text2; SET ae_text2; BY DESCENDING soc_total aebodsys; IF FIRST.aebodsys THEN socord + 1;RUN;Then transpose BY socord aebodsys level aedecod label and use socord instead of aebodsys in the COLUMN and DEFINE statements. The value 9999 keeps the first line (“Subjects with at least one TEAE”) on top.
Exercise 13-5. The log says ERROR: [M_FREQ] The parameter DENOM= is required. and the macro stops before any step: the output data set does not exist (%SYSFUNC(EXIST(...)) returns 0).
Exercise 13-6. In one place: Step 040 of %m_freq, PUT(n / bign * 100, 5.1) becomes PUT(n / bign * 100, 3.). Every table that uses %m_freq follows. The AE table of 13.3 does not use the macro, so it keeps its own rule: one reason to move it to the macros too.
Exercise 13-7. Two lines for the call and one word in the SET statement:
%m_desc(data=refadm.adsl, var=educlvl, by=trt01an, where=saffl = "Y", label=Education (years), ord=8, out=bl_educ)and bl_educ at the end of SET bl_height ... bl_pulse. The section shows n 86, 84, 84; Mean (SD) 12.6 (2.95), 13.2 (4.15), 12.5 (2.92); Median 12.0 in all three columns; Min, Max 6, 21 / 3, 24 / 6, 20.
Exercise 13-8. p = 0.0217. Change the WHERE of step 010 to saffl = "Y" AND trtemfl = "Y" AND aesev = "SEVERE". 29 subjects have a severe TEAE: 5 on placebo, 16 on the low dose, 8 on the high dose. The p-value is the XP2_FISH row of FishersExact (Pr <= P); with PVALUE6.4 it prints as 0.0217.
Exercise 13-9. ModelANOVA, with the label “Type III Model ANOVA”. The log also lists ClassLevels, NObs, OverallANOVA and FitStatistics before it.
Chapter 14: Listings, figures and delivery
Section titled “Chapter 14: Listings, figures and delivery”Exercise 14-1. 92 subjects: 8 on placebo, 44 on the low dose, 40 on the high dose.
DATA disc_ae; SET refadm.adsl(WHERE=(saffl = "Y" AND dcreascd = "Adverse Event")); KEEP trt01an trt01a usubjid trtedt;RUN;PROC SORT DATA=disc_ae; BY trt01an usubjid; RUN;PROC REPORT DATA=disc_ae NOWD HEADLINE; COLUMN trt01an trt01a usubjid trtedt; DEFINE trt01an / ORDER NOPRINT; DEFINE trt01a / ORDER "Treatment" WIDTH=20; DEFINE usubjid / DISPLAY "Subject" WIDTH=11; DEFINE trtedt / DISPLAY "Last dose" WIDTH=9 FORMAT=DATE9.;RUN;Exercise 14-2. paramcd = "SYSBP", and add atptn to the CLASS statement. Draw one panel per position (PROC SGPANEL, PANELBY atpt), or keep one position.
Exercise 14-3. 49 placebo subjects are still at risk at day 90. Check: SELECT COUNT(*) FROM refadm.adtte WHERE trtan = 0 AND aval >= 90;.
Exercise 14-4. STYLE=RTF draws a border around every cell and gives the header row a grey background. Journal draws lines only above and below the header and below the table. The numbers and the layout do not change: the style changes only how the table looks.
Exercise 14-5. 41 records of 29 subjects. Sort by trtan usubjid astdt aedecod, count the subjects in a DATA step (IF FIRST.usubjid THEN nsubj + 1;) and set pg = CEIL(nsubj / 10);: pg goes from 1 to 3. The file has 7 pages, not 3: the events of 10 subjects do not fit on one page, so PROC REPORT continues on the next page by itself. BREAK AFTER pg / PAGE only forces the extra breaks.
Exercise 14-6. 13 pages (“Page 1 of 13”). Put the PROC REPORT step of 13_2_table_ae.sas between the ODS RTF and ODS PDF statements of 14_3_rtf_demog.sas, with the margins and with widths that fit: 4.2 inches for the label and 1.5 inches for each treatment, 8.7 inches in all. Add asis=on to the label column, or the preferred terms lose their indent. Page 1 starts with “Subjects with at least one TEAE 65 (75.6) 77 (91.7) 76 (90.5)”, as the table of section 13.3.