Hi everyone,
I've been working on a demographics table for a study. After some data manipulation, I obtained a data set like this. Please note that the p-values are fictive.
Using PROC REPORT with COMPUTE block and LINE statement, I can create a header line for each variable.
/* Create data set DemoPatients */
data DemoPatients;
input SubID ID Variable $ Label $ strat_1 strat_2 total pvalue;
label Variable = "Parameter"
strat_1 = "A|(N = 187)"
strat_2 = "B|(N = 187)"
total = "Total|(N = 374)"
pvalue = "p-value";
datalines;
1 1 Gender F 109 117 226 0.0001
2 1 Gender M 78 70 148 0.0001
3 2 Race 5 49 30 79 0.0254
4 2 Race 6 138 157 295 0.0254
5 3 Complete 0 5 3 8 0.0005
6 3 Complete 1 182 184 366 0.0005
;
run;
/* Output */
ods escapechar="^";
options nodate nonumber orientation=portrait;
ods rtf file="C:\Demographics and Baseline Characteristics of Patients %sysfunc(date(),yymmdd10.).doc" style=MyStyle bodytitle;
/* Apple Header, Line, and Column Styles in PROC REPORT Statement */
proc report data=DemoPatients nowd center split="|"
/*style(report)=[cellpadding=0.5pt]*/
style(header)=[just=c font_weight=bold asis=on]
style(lines)=[just=l]
style(column)=[just=l cellwidth=1in];
/* Add Bottom Cell Borders and Create A Spanning Header */
columns id variable subid label
("^{style [borderbottomwidth=1pt] Treatment}" strat_1-strat_2) total;
/* Use ORDER ORDER=INTERNAL NOPRINT to Order Rows and Suppress Printing */
/* For Ordering, the variables must be left-most in the COLUMNS statement */
define id / order order=internal noprint;
define variable / order noprint;
define subid / order order=internal noprint;
define label / "Parameter" order order=data
style(header)=[just=l indent=0in]
style(column)=[just=l cellwidth=3in indent=0.25in];
/* Create Row Headers via COMPUTE Block LINE Statements */
compute before variable / style={color=black backgroundcolor=white};
line " ";
line variable $200.;
endcomp;
run;
ods rtf close;
title;
footnote;
Here is the result from the SAS code above:
Now I've wanted to add a column named "p-value" to right side of this table using the same syntax but no luck so far. This is what I want to produce with the p-value aligns with the variable's name.
I would really appreciate any suggestions.
Thanks.
You say "same syntax" but don't say which same syntax.
Show exactly what you tried.
What I meant was the same way COMPUTE block generated the header for each variable's name.
...
columns id variable subid label
("^{style [borderbottomwidth=1pt] Treatment}" strat_1-strat_2) total
pvalue;
...
define pvalue / order noprint;
/* Create Row Headers via COMPUTE Block LINE Statements */
compute before variable / style={color=black backgroundcolor=white};
line " ";
line variable $200. pvalue pvalue6.4;
endcomp;
Updated the first post with a dummy data set.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.