BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
willy0625
Calcite | Level 5

I have a dataset:

RBCDEF
Boarding340.32352911-3612%
Buyer170.05882413916%
Living w400.1%
Other50.21222%
Owner700.142857108425%
Renting1500.2842-2253%
Supplied111-1000%

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

View solution in original post

5 REPLIES 5
ArtC
Rhodochrosite | Level 12

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;

willy0625
Calcite | Level 5

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

ArtC
Rhodochrosite | Level 12

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;

willy0625
Calcite | Level 5

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

Ksharp
Super User

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

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 765 views
  • 6 likes
  • 3 in conversation