I have a dataset:
R | B | C | D | E | F |
Boarding | 34 | 0.323529 | 11 | -36 | 12% |
Buyer | 17 | 0.058824 | 1 | 391 | 6% |
Living w | 4 | 0 | 0 | . | 1% |
Other | 5 | 0.2 | 1 | 22 | 2% |
Owner | 70 | 0.142857 | 10 | 84 | 25% |
Renting | 150 | 0.28 | 42 | -22 | 53% |
Supplied | 1 | 1 | 1 | -100 | 0% |
What sas code would you write to turn this into a nice table for documentation? - I currently have a SAS tabulate but just cant get what I want.
- Could I have some tips for editing tables? labeling of the variables, titles, font centering, size, borders etc.
Thanks
Add it into ArtC's code.
But I recommend you to post it into ODS and report Forum. There is a SAS man named Cynthia who is very good at this.
And If you need more control about report ,I think Cynthia will help you a lot.
data types; input curr_resiStatus $ count bad Total_Bad Index participants :percent.; format participants percent.; datalines; Boarding 34 0.323529 11 -36 12% Buyer 17 0.058824 1 391 6% Livingw 4 0 0 . 1% Other 5 0.2 1 22 2% Owner 70 0.142857 10 84 25% Renting 150 0.28 42 -22 53% Supplied 1 1 1 -100 0% run; title1 'This is a title'; ODS RTF BODY='tables.rtf' style=Journal ; proc report data=types nowd out=test; columns ('Spanning Text' curr_resiStatus count bad Total_Bad Index participants) ; define count/style={cellwidth=4cm}; compute curr_resiStatus; if _BREAK_='_RBREAK_' then curr_resiStatus='Total'; endcomp; rbreak after / summarize; run; ODS RTF CLOSE;
Ksharp
Without knowing what you want your table to look like it is very hard to guess what to show to you. Here is some code that changes variable names, variable labels, titles, and text. Since there is no data to summarize, TABULATE seems a less likely choice.
data types;
input Type $ B C D E F :percent.;
label b = 'count';
datalines;
Boarding 34 0.323529 11 -36 12%
Buyer 17 0.058824 1 391 6%
Livingw 4 0 0 . 1%
Other 5 0.2 1 22 2%
Owner 70 0.142857 10 84 25%
Renting 150 0.28 42 -22 53%
Supplied 1 1 1 -100 0%
run;
title1 'My Special Data';
proc print data=types;
run;
proc report data=types nowd;
columns Type B C D E F;
define c / display 'R O I';
run;
ODS RTF BODY='tables.htm' style=Journal;
proc print data=data NOOBS;
run;
ODS RTF CLOSE;
produces
curr_resiStatus | count | bad | total_bad | Index | participants |
Boarding | 34 | 0.32353 | 11 | -36 | 12% |
Buyer | 17 | 0.05882 | 1 | 391 | 6% |
Living w | 4 | 0.00000 | 0 | . | 1% |
Other | 5 | 0.20000 | 1 | 22 | 2% |
Owner | 70 | 0.14286 | 10 | 84 | 25% |
Renting | 150 | 0.28000 | 42 | -22 | 53% |
Supplied | 1 | 1.00000 | 1 | -100 | 0% |
which is what I want, except, I would like to add a bar at the bottom of the table for the total figures and also I would like to perform
hsplit so that the upper part of the table looks like
curr_resiStatus | |||||
Count | Bad | Total_bad | Index | participants | … |
Much clearer. I am still not quite sure what we are doing with the first column, but the following makes sense to me as a next step closer. I added a title and some spanning text in a REPORT step. I also changed the ODS file extension to RTF.
data types;
input curr_resiStatus $ count bad Total_Bad Index participants :percent.;
format participants percent.;
datalines;
Boarding 34 0.323529 11 -36 12%
Buyer 17 0.058824 1 391 6%
Livingw 4 0 0 . 1%
Other 5 0.2 1 22 2%
Owner 70 0.142857 10 84 25%
Renting 150 0.28 42 -22 53%
Supplied 1 1 1 -100 0%
run;
title1 'This is a title';
ODS RTF BODY='tables.rtf' style=Journal;
proc report data=types nowd;
columns ('Spanning Text' curr_resiStatus count bad Total_Bad Index participants) ;
rbreak after / summarize;
run;
ODS RTF CLOSE;
Just a couple of more things: How do you add another horizontal bar between the last line and the second to the last line so that I have a nice last row that looks like
-----------------------------------
total 3582 1016 . . . .
-----------------------------------
I am also trying to manipulating the space between the columns, How would you do this?
Many thanks
Add it into ArtC's code.
But I recommend you to post it into ODS and report Forum. There is a SAS man named Cynthia who is very good at this.
And If you need more control about report ,I think Cynthia will help you a lot.
data types; input curr_resiStatus $ count bad Total_Bad Index participants :percent.; format participants percent.; datalines; Boarding 34 0.323529 11 -36 12% Buyer 17 0.058824 1 391 6% Livingw 4 0 0 . 1% Other 5 0.2 1 22 2% Owner 70 0.142857 10 84 25% Renting 150 0.28 42 -22 53% Supplied 1 1 1 -100 0% run; title1 'This is a title'; ODS RTF BODY='tables.rtf' style=Journal ; proc report data=types nowd out=test; columns ('Spanning Text' curr_resiStatus count bad Total_Bad Index participants) ; define count/style={cellwidth=4cm}; compute curr_resiStatus; if _BREAK_='_RBREAK_' then curr_resiStatus='Total'; endcomp; rbreak after / summarize; run; ODS RTF CLOSE;
Ksharp
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.