TableEditor
Control
elements
enable your extension node to access SAS data sets that are accessible
by the SAS Enterprise Miner server or that are generated by your extension
node's server code. The server code that is required for a TableEditor
Control
is
typically minimal. The essential purpose of the server code is to
provide a way for the SAS Enterprise Miner server to identify and
track the data sets or files that are to be accessed by the Control
.
The Control
elements also typically provide
a way for you to add more sophisticated functionality beyond the minimal
requirements.
String
Property
with
a TableEditor
Control
:
<Property description="write your own description here" displayName="TableEditor Control Example" name="TableEditor" type="String"> <Control> <TableEditor key="COMPANY"> <Actions> <Open name="OpenTable" /> <Close name="CloseTable" /> </Actions> </TableEditor> </Control> </Property>
Control
element. This Control
element
has no attributes. Nested inside this Control
element
is a single TableEditor
element. The TableEditor
element
has a key
attribute. The value of the key
attribute
is the name of a file key that you register using the %EM_REGISTER
macro. In this example, the node prefix is EXMPL and the key
is
COMPANY, so the name of the table is EMWS.EXMPL_COMPANY.
key
.
For example, you might have code in the CREATE action that registers
the key
, COMPANY, and a SAS DATA step that
associates the key
with the data set Sashelp.Company:
%em_register(type=data,key=COMPANY,property=Y); data &EM_USER_COMPANY; set sashelp.company; run;
TableEditor
Control
is
not created until after the node is run. The data set might be created
by a process within the TRAIN code. In that case, you could still
register the key in your CREATE code, but the code that associates
the key with the data set would be in your TRAIN code. If the user
attempted to open the table before the node was run, an error message
would appear indicating that the table does not exist.
TableEditor
element
is an Actions
element. The Actions
element
associates a block of SAS code with a user action. Inside the Actions
element
are an Open
element and a Close
element;
both have a name
attribute. In your node's
main program, you can add code that might look like this:
%if %upcase(&EM_ACTION) = OPENTABLE %then %do; filename temp catalog 'sashelp.emext.example_actions.source'; %include temp; filename temp; %OpenTable; %end; %if %upcase(&EM_ACTION) = CLOSETABLE %then %do; filename temp catalog 'sashelp.emext.example_actions.source'; %include temp; filename temp; %CloseTable; %end;
name
attributes
correspond to the names of the actions that are executed when the
user either opens or closes the table. The following actions occur
when the user opens the table by clicking the ellipsis () icon:
Open
action
(for example, OpenTable
) before the server
code is processed.
OpenTable
action
that is specified in the Open
element executes
before a copy of the table is returned to the client.
Close
action (for
example, CloseTable
) before the server code
is processed.
CloseTable
action
that is specified in the Close
element executes.
Open
or Close
)
specified in the XML properties file for a TableEditor
Control
.
However, you are not required to write any code or to include a call
to the action in your main program. When you do not have any code
that you want to execute when the table is opened or closed, the Actions
, Open
,
and Close
elements act as placeholders.
Column
element
with nested Column
elements enables you to
control which variables appear in the table and whether a variable's
values can be edited by the user. In the following example, the Control
configuration
restricts which variables are displayed in the table and enables the
user to edit the values of those variables:
<Property description="write your own description here" displayName="TableEditor Control Example" name="TableEditor" type="String"> <Control> <TableEditor key="COMPANY"> <Actions> <Open name="OpenTable"/> <Close name="CloseTable"/> </Actions> <Columns displayAll="N"> <Column name="DEPTHEAD" type="String" editable="Y"/> <Column name="JOB1" type="String" editable="Y"/> <Column name="LEVEL3" type="String" editable="Y"/> <Column name="N" type="int" editable="Y"/> <Column name="LEVEL4" type="String" editable="Y"/> </Columns> </TableEditor> </Control> </Property>
Columns
element,
the displayAll
attribute has a value of N.
This indicates that only those variables that are specifically identified
by Column
elements should appear when the
table is opened. Four Column
elements are
specified. In each Column
element, there
are three attributes defined as follows:
name
—
specifies the name of the variable to display.
type
—
specifies one of four supported types of variables. The supported
types are as follows:
boolean
String
int
double
editable
—
indicates whether the user can modify the variable's values. Valid
values are Y or N.
editable
attribute
of a Column element is set to Y, the user can
edit the values of the corresponding variable by entering a new value
in the SAS Table Editor window.
Range
Control
elements
to restrict the values that can be used to edit the values in the
table. For example, suppose you add a Range
Control
to
the N Column
element
as follows:
<Property description="write your own description here" displayName="TableEditor Control Example" name="TableEditor" type="String"> <Control> <TableEditor key="COMPANY"> <Actions> <Open name="OpenTable" /> <Close name="CloseTable" /> </Actions> <Columns displayAll="N"> <Column name="DEPTHEAD" type="String" editable="Y"> </Column> <Column name="JOB1" type="String" editable="Y"/> <Column name="LEVEL3" type="String" editable="Y"/> <Column name="LEVEL4" type="String" editable="Y"/> <Column name="N" type="int" editable="Y"> <Control> <Range min="1" max="3" /> </Control> </Column> </Columns> </TableEditor> </Control> </Property>
min
and max
values
specified. If they enter a value that is outside of that range, the
value of N is set to missing in that row
of the table.
<Property description="write your own description here" displayName="TableEditor Control Example" name="TableEditor" type="String"> <Control> <TableEditor key="COMPANY"> <Actions> <Open name="OpenTable" /> <Close name="CloseTable" /> </Actions> <Columns displayAll="N"> <Column name="DEPTHEAD" type="String" editable="Y"> <Control> <ChoiceList> <Choice displayValue="1" rawValue="1"/> <Choice displayValue="2" rawValue="2"/> </ChoiceList> </Control> </Column> <Column name="JOB1" type="String" editable="Y"/> <Column name="LEVEL3" type="String" editable="Y"/> <Column name="LEVEL3" type="String" editable="Y"/> <Column name="N" type="int" editable="Y"> <Control> <Range min="1" max="3" /> </Control> </Column> </Columns> </TableEditor> </Control> </Property>
Range
Control
,
a missing value appears in that observation.
DynamicChoiceList
Control
enables
you to dynamically populate a choice list rather than hardcoding values
in the XML properties file. The following example demonstrates the
functionality that this control provides as well as the steps necessary
to implement it. There are four steps to implementing this type of Control
.
Property
configuration
appears as follows:
<Property description="write your own description here" displayName="TableEditor Control Example" name="TableEditor" type="String"> <Control> <TableEditor key="COMPANY" choiceKey="CHOICE"> <Actions> <Open name="OpenCompanyTable" /> </Actions> <Columns displayAll="N"> <Column editable="Y" name="DEPTHEAD" type="String"> </Column> <Column name="JOB1" type="String" editable="Y"> <Control> <DynamicChoiceList/> </Control> </Column> <Column name="LEVEL3" type="String" editable="Y"/> <Column name="LEVEL4" type="String" editable="Y"/> <Column name="N" type="int" editable="Y"> </Column> </Columns> </TableEditor> </Control> </Property>
TableEditor
element
now has a choiceKey
attribute with a value
of CHOICE. The Column
element
for JOB1 now has a Control
element
with a nested DynamicChoiceList
element.
In the CREATE action, the following line of code is added:
%em_register(type=data, key=CHOICE);
DynamicChoiceList
is
in the OPEN action. However, it can actually be placed wherever it
is most appropriate for the purpose that it serves. In this example,
the code is placed in the CREATE action so that the SAS Table Editor
is functional when the node is first placed in a process flow diagram.
DynamicChoiceList
is
populated with the unique values of that variable. The following code
generates the data set:
proc sort data=sashelp.company nodupkey out=&em_user_choice(keep=LEVEL4); by LEVEL4; run; data &em_user_choice(keep=Variable Choice); length Variable $32 Choice $32; set &em_user_choice; Variable="LEVEL4"; Choice=LEVEL4; run;
choiceKey
attribute of the TableEditor
element.
name
attribute of the Column
element
to which the DynamicChoiceList
element is
applied.
Choice
variable. These unique values
are the choices that populate the DynamicChoiceList
.
DynamicChoiceList
element
can be applied to multiple Column
elements
in a TableEditor
Control
.
In such a case, the data set has a repeated measures structure. That
is, suppose that there are k Column
elements
to which you want to apply a DynamicChoiceList
.
You still create one data set to populate the k lists. The data set
has the following structure:
Variable Choice variable-name_1 value 1_1 variable-name_1 value 1_2 variable-name_1 ... variable-name_1 value 1_N1 variable-name_2 value 2_1 variable-name_2 value 2_2 variable-name_2 ... variable-name_2 value 2_N2 . . . . . . variable-name_k value k_1 variable-name_k value k_2 variable-name_k ... variable-name_k value k_Nk
whereClause
and whereColumn
attributes
to the TableEditor
element. For example,
change the TableEditor
element as follows:
<TableEditor key="COMPANY" choiceKey="CHOICE" whereClause="Y" whereColumn="DEPTHEAD">
whereClause
attribute
is redundant, but it is required; it should have a value of Y.
The whereColumn
specifies the name of a variable
in the data set. Including these two attributes sorts the data set
by the values of the variable specified in the whereColumn
attribute.
A drop-down list is added at the top of the SAS Table
Editor window. The values in the list correspond to the
unique values of the variable specified in the whereColumn
attribute
and the additional value of All. By default,
only observations with a value corresponding to the first value in
the list are displayed. The user can then select a different value
from the drop-down list; the table is refreshed and the observations
that correspond to the new value are displayed. If the user selects All,
the entire table is displayed.
DynamicChoiceList
Control
. By
adding a single new attribute and modifying the accompanying SAS code,
you can take advantage of the hierarchical structure of the SASHelp.Company
data set to restrict the values that are used to populate the choices.
For example, consider the following modified Property
configuration:
<Property description="write your own description here" displayName="TableEditor Control Example" name="TableEditor" type="String"> <Control> <TableEditor key="COMPANY" choiceKey="CHOICE" keyVar="LEVEL3" whereClause="Y" whereColumn="DEPTHEAD"> <Actions> <Open name="OpenCompanyTable" /> <Close name="CloseCompanyTable" /> </Actions> <Columns displayAll="N"> <Column editable="Y" name="DEPTHEAD" type="String"/> <Column name="JOB1" type="String" editable="Y"/> <Column name="LEVEL3" type="String" editable="Y"/> <Column name="LEVEL4" type="String" editable="Y"> <Control> <DynamicChoiceList/> </Control> </Column> <Column name="N" type="int" editable="Y"/> </Columns> </TableEditor> </Control> </Property>
keyVar
attribute
of the TableEditor
Control
.
In this example, the keyVar
attribute is
assigned the value of "LEVEL3". This means that when the
choices for the variable LEVEL4 are presented for a given row in the
table, the choices are conditional on the value of LEVEL3 in the same
row of the table. To accomplish this, a table with a hierarchical
structure of choices must be generated as follows:
%em_register(type=data, key=CHOICE) proc sort data=sashelp.company nodupkey out=&em_user_choice(keep= LEVEL3 LEVEL4); by LEVEL3 LEVEL4; run; data &em_user_choice(keep=Variable Choice key); length Variable $32 Choice $32 key $32; set &em_user_choice; Variable="LEVEL4"; Choice=LEVEL4; key=LEVEL3; run;
choiceKey
attribute of the TableEditor
element.
Column
element
to which the DynamicChoiceList
is applied.
DynamicChoiceList
.
Property
configuration
is as follows:
<Property description="write your own description here" displayName="Ordering Editor Control Example" name="OrderingEditor" type="String"> <Control> <TableEditor key="ORDER" isOrderingEditor="Y"> <Actions> <Open name="OpenOrderTable" /> <Close name="CloseOrderTable" /> </Actions> <Columns displayAll="Y"> <Column editable="N" name="NAME" type="String"/> </Columns> </TableEditor> </Control> </Property>
TableEditor
Control
: key
and isOrderingEditor
.
Just as in the other TableEditor
Control
example,
the value of the key
attribute must be registered
with SAS Enterprise Miner using the %EM_REGISTER macro in your extension
node's server code. The isOrderingEditor
attribute
tells SAS Enterprise Miner that this table editor is, in fact, an
ordering editor.
Actions
element
and at least one named action nested within it. However, the named
action need not have any server code associated with it. You control
which variables appear in the table with the Columns
element
and the nested Column
elements. You can have
as many columns in the table as you want.
%em_register(type=data, key=ORDER); proc contents data=sashelp.company out=&em_user_order(KEEP=NAME); run;