Looking for a way to insert a row above each section of a table. For example, a table can have Races and Age groups like this:
Variable Value
White 50
Black 60
Asian 10
Other 20
<20 15
20-30 7
30-50 8
50-75 25
>75 60
In the report, I'd like to display this:
Variable Value
R A C E
White 50
Black 60
Asian 10
Other 20
A G E G R O U P
<20 15
20-30 7
30-50 8
50-75 25
>75 60
Appreciate any suggestions.
Haris
How are you generating the tables currently? Code example?
Tables are all generated outside of PROC REPORT using SQL, FREQ, MEANS, etc. It's for the demographics table of a manuscripts with predictors as rows, groups as columns, Ns, p-values, etc. At the moment, I am only interested in making the output prettier and removing the manual step of adding the section headings. I don't think what I am looking for can be made entirely in PROC REPORT or any one procedure for that matter.
Thanks,
Haris
Proc Tabulate actually does similar to what you want.
Take a look at the output from:
proc tabulate data=sashelp.class;
class sex;
class age;
table sex age,
n=''*f=f4.0;
run;
But without some details of what your data looks like and what you have tried, we can't get much further.
Summarized data can be displayed using FILE Print and Put statements in a data step if you need something other than "simple" tables, but again we need to know what the data looks like.
Without more specifics it's hard to say what approach to follow. Adding a "space" between the header/column names and the rest of the table is doable -- all depends on the approach(es) you are using.
And thought I was as clear as it gets
Here's the code for full table as well as a PROC REPORT I am currently using--it's a standard table 1 from any medical journal:
data have;
input Variable $;
N1 = ranuni(0); N2 = ranuni(0);
Group1 = put(ranuni(0),8.2); Group2 = put(ranuni(0),8.2);
PVal= ranuni(0);
cards;
Var1
Var2
Var3
Var4
AgeGr1
AgeGr2
AgeGr3
Race1
Race2
Race3
Region1
Region2
Region3
Region4
;
run;
proc report data=have;
column ('Predictor' Variable)
('Number of Patients' N1 N2)
('Mean/STD' Group1 Group2)
('p-value' PVal);
define Variable / display '';
define N1 / display center;
define N2 / display center;
define Group1 / display center;
define Group2 / display center;
define Pval / display center '';
run;
Output is the table below (for some reason the (headers are cut off but they don't matter). At the moment I am typing the bold category headings manually and would like to automate it. Tried COMPUTE BEFORE but got lost.
Other Pt Variables | |||||
A | 0.9945648 | 0.4985552 | 0.32 | 0.12 | 0.6276928 |
B | 0.0805072 | 0.6616233 | 0.05 | 0.23 | 0.4454616 |
C | 0.9524591 | 0.6282662 | 0.03 | 0.38 | 0.304287 |
D | 0.5737679 | 0.1142044 | 0.57 | 0.49 | 0.7099973 |
Age Group | |||||
AgeGr1 | 0.9518248 | 0.2908635 | 0.35 | 0.89 | 0.6725817 |
AgeGr2 | 0.507329 | 0.5758729 | 0.84 | 0.09 | 0.6611321 |
AgeGr3 | 0.5157527 | 0.4067989 | 0.98 | 0.40 | 0.4416961 |
Race | |||||
Race1 | 0.1075504 | 0.9987347 | 0.96 | 0.25 | 0.5914531 |
Race2 | 0.9669518 | 0.6722821 | 0.88 | 0.48 | 0.4796646 |
Race3 | 0.8172502 | 0.8970209 | 0.42 | 0.07 | 0.6066189 |
Geographical Region | |||||
Region1 | 0.6131752 | 0.7856588 | 0.40 | 0.52 | 0.0752222 |
Region2 | 0.9814383 | 0.9802798 | 0.48 | 0.52 | 0.6117008 |
Region3 | 0.176767 | 0.2434878 | 0.82 | 0.66 | 0.6990772 |
Region4 | 0.8758262 | 0.9445898 | 0.72 | 0.54 | 0.8402694 |
Hi,
This paper has several examples of this type of demographic report.
http://www2.sas.com/proceedings/forum2008/173-2008.pdf
In addition if you search PharmaSUG papers at lexjansen.com, you should find more examples.
cynthia
Hi
You can use the COMPUTE BEFORE with a LINE statement to do something like this, see sample code below. For the grouping you need a new variable which is not shown in the report but needed to have "break lines".
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.