Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format particular cells in Proc Tabulate 1

Status
Not open for further replies.

nobyrnes

Programmer
Mar 20, 2007
15
IE
Hey,
I create a table say 5cells by 5cells. I can use the code below to colour the background of a column of cells however I want to colour just particular cells. (I dont want to colour on a condition of the contents of a cell). For example I want to colour the first 2 cells of the first 2 rows red, and then other 3 cells in the same 2 rows blue???
Any help please,
Niall


PROC TABULATE
DATA=&Datain;
CLASS Segment_X Segment_Y;
TABLE Segment_Y=' ' all=' '*{s=< parent >{background=grey}} , (Segment_X='Turnover Segment' all=' ' )*N=' '/MISSTEXT='None';
 
Sorry, I don't think that's possible. SAS works in rows and columns, not cells. You might be able to do it using proc report using a compute step to change the background colour, but it would be pretty complex... You'd have to do it as if you were doing conditional formatting, but set up variables to keep track of position and use them to set the colours. Even then, might not be possible.

As an alternative, how about setting up a macro in Excel and using that to fix the colours?

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Hey, Thanks Chris,
Ive been making Excel format those cells that I want, however when I open the file in a browser afterwards, it has lost most of the other formatting, like <center> etc...

How can I use that traffic lighting and also maintain the contents of the cell (the value of the cell will never be related to the colour)...

N
 
You may need to set ALL the parameters again. It might be that setting a couple of style parameters creates a new "style" which has defaults for the others. I think you'll have to set all of them.
Alternatively, and I'm not entirely sure if you can do this, but if you CAN tell it to use a named style, rather than just setting style attributes, you can use Proc Template to set up the relevant styles using the main style as a parent..


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Hey,
I tried all these and only one worked:

1.Using excel loses formatting, particularly when there are many tables.
2.Using css doesn't work, because it is impossible to set up an external style sheet to colour each cell of a row, (unless you set up each cell as a <div id="xx">but SAS cant do this.)

3.Use a background picture.
In Your proc templete set the table up as fixed-width, then make an image and set to your background in proc template.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top