DATA Step, Macro, Functions and more

Centering the bottom 'total' line in a Proc Tabulate report

Reply
Occasional Contributor
Posts: 15

Centering the bottom 'total' line in a Proc Tabulate report

The code below produces a report my customer wants EXCEPT that the bottom row, which is a total of all the values above it, is right justified and all the other cells are center justified.   They object to that.  The bottom row is also colored differently by design.    I know this is probably a simple fix but i've put 'just=R' everyplace I can think of and just can't get it to justify that bottom row.    Any ideas??  I had to add the Total=R on the label line to get the label to be right justified which it needs to be.  I suspect that is causing everything on that row to be that way.   So maybe another way of stating the problem is how can I get ONLY the label to be right justified and the values to be centered?

 

---------------------  code  ----------------------------

proc tabulate data =&input f=4.0 S=[just=c cellwidth=25]; 
var Col1;
class criterion instrument /ORDER=DATA ;
class _name_ ;
table instrument*criterion all={label='Total' s=[just=R background=goldenrod]}*{s=[background=goldenrod]} ,(_name_='Level' ALL)*Col1=" "*(sum="N"*(f=3.0) ROWPCTSUM="%"*f=mypct. ) /box=&reportdate; 
BY instrument NOTSORTED; 
run;

 

 

Super User
Posts: 11,343

Re: Centering the bottom 'total' line in a Proc Tabulate report

When a single row needs a different appearance then that may mean that Proc Report is a better option as it allows a separate define block for breaking rows, which I think is what you are attempting. Unfortunately if you have nearly working Tabulate code there is not an easy translation to Report and statistic calculations are done quite differently for percentages.

Occasional Contributor
Posts: 15

Re: Centering the bottom 'total' line in a Proc Tabulate report

Thanks but I don't want the row to have a different justification, I want all the rows to have same justification.   The problem I'm having is that the last row is NOT like the others.  I'd be happy if they were all left, right or center justified (we prefer centered) but the body of the report is center justified and the total row at the bottom is right justified.   I personally don't care but my university client think it looks sloppy and can't believe it can't be fixed since they can make it look right when they do it in Excel!  Smiley Happy   I'm doing this to automate the production of hundreds of reports which they currently manually create in Excel.

 

You are correct that at this point, we've done too much work to change to a different report writer.   I used Proc Tabulate so it would be compatible with other reports they already use it for so  whoever is going to maintain this will have the same report Proc for everything.  Everything is fine except that last row justification problem.

 

 

Bill

 

Super User
Posts: 11,343

Re: Centering the bottom 'total' line in a Proc Tabulate report

Your code says to use two different justifications. The S=[just=C cellwidth=25] on the proc statement sets a default and then you have Just=R for the ALL. Which is why I thought you were attempting two different behaviors.

 

It would help to provide some data to test code with, dummy is fine as long as it behaves the same.

 

It will also help to provide which ODS destination you are using and the ODS style you are using. 

When I use a different data set with similar tabulate code with HTML destination and Meadow style the Total row label is right justified with the colored background and all of the summary cells centered.

 

 

Ask a Question
Discussion stats
  • 3 replies
  • 253 views
  • 0 likes
  • 2 in conversation