Date: Thu, 18 Jul 2002 08:21:17 -0400
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Organization: MindSpring Enterprises
Subject: Re: Color in a data table (SAS AF)
"Nathalie Bini" <nabnews@EXCITE.COM> wrote in message
> I'm back again with a question.
> Does someone kwon how I can set a background color for some rows in a
> table component?
> I mean : I have a data table filled with a data set that contains +/- 10
> columns and 30 rows, there is one column named "error", this one
> contains '.' or 1 if there is an error.
> What I want is to set a background color for all the rows where error =
> I already found how to set a background color for a column, but I can't
> find anything for a row.
There is plenty of info in Online Help, look for ModelSCL.
You need to set the .modelSCLEntry attribute of the Data Table's model (as
well as the .table attribute).
The .modelSCLEntry value is the name of a SAS SCL entry (e.g.
In this SCL entry you can manipulate how the viewer (the Data Table)
renders a data value.
You can also do anything else you can imagine.
The model SCL has important tacit sections
DFINIT: is run once when table is first created
INIT: is run each time an observation is fetched by the viewer
TERM: is run when an observation is becoming not the current row (e.g. a
selected row that is becoming unselected)
MAIN: is run whenever a data value is changed or enter is pressed
DFTERM: is run once when table is being destroyed
The modelSCL can only be compiled from within the Build GUI, off the
DataTable context menu (right click on table) Table->Compile SCL. (You can
compile it with SCL editor if entered through Table->Edit SCL)
The above is necessary so
1. the column names of the table are implicitly available as SCL variables
whose value corresponds to the current row.
2. the modelSCL can also respond to table column named sections of SCL
e.g. if table has column named AGE and modelSCL has section AGE:, then the
code in AGE: section will run when ever AGE is edited.
As for changing visualization of a cells data, you can use the
_setViewerAttribute() method from within the modelSCL.
In your case you need to iterate across all columns of a row and set the
background color of each cell in a row.
collist = makelist();
* Note: SCL variable 'error' is implicitly available since the model
.table points to a table
* containing a column named 'error';
if error=1 then do;
do i = 1 to listlen (collist);
_self_._setViewerAttribute (getitemc (collist,i), 'BCOLOR', 'RED');
_self_._setViewerAttribute (getitemc (collist,i), 'FCOLOR', 'WHITE');
rc = dellist (collist);
Richard A. DeVenezia