![]() | ![]() | ![]() | ![]() | ![]() |
This example shows you how to generate a simple hierarchical tree graphic by using the Treeview HTML Generator. The following steps explain the process of creating the graphic:
Use the following code to generate a data set that contains the parent/child relationships:
%let htmlfile=full path of html file.html; %let codebase=location where treeview.jar file is on your system; data myorg; input name $ empno mgrno deptname $28. deptcode $; cards; Peter 2620 1420 Documentation DOC Linda 6915 1420 Research and Development R&D Maria 1320 1420 Legal LGL Vince 1420 1750 Executive EXE Jim 6710 6915 Quality Assurance QA Nancy 22560 6915 Quality Assurance QA Patrick 28470 6915 Quality Assurance QA Elsa 33075 6915 Development DEV Clement 22010 6915 Development DEV Murielle 3020 6915 Development DEV David 11610 6915 Research RES ; run;
The following statements require user input:
%LET HTMLFILE=, which specifies the location where you want to store the HTML file. Change this statement so that full path of html file.html specifies the location where you want to store the HTML file.
%LET CODEBASE=, which specifies the location of the treeview.jar file. Change this statement so that location where treeview.jar file is on your system specifies the location of the treeview.jar file.
Use the following code to construct a SAS format. This format, which illustrates the use of the NCOLFMT= argument, provides an easy way to alter the color of the nodes without modifying the underlying SAS data set. For example, if you want to change the color of the nodes representing the QA department, then you change the color value wheat specified in the format, not in the data set.
proc format;
value $nodecol 'DOC'='orange'
'R&D'='#00ff80'
'LGL'='#f5b6f1'
'EXE'='#0080FF'
'QA'='wheat'
'DEV'='#FF8080'
'RES'='#a5aff5';
run;
quit;
Use the following code to issue TITLE and FOOTNOTE statements and run the DS2TREE macro that builds the graphic:
title1 'Organizational Chart for a Hypothetical Company';
footnote1 'Hover over a node to display the department name.';
footnote2 'Click and drag a node to rotate the tree.';
%ds2tree(ndata=myorg,
archive=treeview.jar, codebase=&codebase,
htmlfile=&htmlfile, cback=white,
nid=empno,
nparent=mgrno, spread=2.0,
ntip=deptname,
nlabel=name,
ncolor=deptcode, ncolfmt=$nodecol.,
height=500, width=600, cutoff=1.0,
septype=none, center=y, brtitle=SAS Treeview Sample,
ttag=header 2, tcolor=navy,
tface=%str(Arial,Helvetica,sans-serif),
ftag=header 4, fcolor=navy,
fface=%str(Arial,Helvetica,sans-serif));
The following parameters are among those that were used in this sample code:
NID=EMPNO and NPARENT=MGRNO2, which specify the names of the variables in the data set that represent the child and parent nodes, respectively.
NTIP=DEPTNAME and NLABEL=NAME, which specify the names of the variables in the data set to be used for the floating tool tips and the node labels, respectively.
NCOLOR=DEPTCODE, which specifies the name of the variable in the data set to be used for the node colors. Note that the values of the variable DEPTCODE are not valid HTML colors.
NCOLFMT=$NODECOL., which specifies the name of the SAS format that is to be applied to the node color variable (DEPTCODE) in order to produce valid HTML color names.
For a comprehensive list and description of all the parameters, see the Treeview HTML Generator documentation.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
%let htmlfile=full path of html file.html;
%let codebase=location where treeview.jar file is on your system;
/* Create the data set MYORG */
data myorg;
input name $ empno mgrno deptname $28. deptcode $;
cards;
Peter 2620 1420 Documentation DOC
Linda 6915 1420 Research and Development R&D
Maria 1320 1420 Legal LGL
Vince 1420 1750 Executive EXE
Jim 6710 6915 Quality Assurance QA
Nancy 22560 6915 Quality Assurance QA
Patrick 28470 6915 Quality Assurance QA
Elsa 33075 6915 Development DEV
Clement 22010 6915 Development DEV
Murielle 3020 6915 Development DEV
David 11610 6915 Research RES
;
run;
/* The format $NODECOL is created to illustrate the use of the NCOLFMT */
/* argument. This provides an easy way to alter the color of the nodes */
/* without modifying the underlying SAS data set. For example, if you */
/* want to change the color of the nodes representing the QA department,*/
/* you simply make a change to the color value specified in the format, */
/* not in the data set. */
proc format;
value $nodecol 'DOC' = 'orange'
'R&D' = '#00ff80'
'LGL' = '#f5b6f1'
'EXE' = '#0080FF'
'QA' = 'wheat'
'DEV' = '#FF8080'
'RES' = '#a5aff5';
run;
quit;
title1 'Organizational Chart for a Hypothetical Company';
footnote1 'Hover over a node to display the department name.';
footnote2 'Click and drag a node to rotate the tree.';
/* NID=EMPNO and NPARENT=MGRNO specify the names of the variables in the */
/* data set that represent the child and parent nodes, respectively. */
/* NTIP=DEPTNAME and NLABEL=NAME specify the names of the variables in */
/* the data set to be used for the floating tool tips and the node names,*/
/* respectively. */
/* NCOLOR=DEPTCODE specifies the name of the variable in the data set */
/* to be used for the node colors. Note that the values of the variable */
/* DEPTCODE are not valid HTML colors. NCOLFMT=$NODECOL. specifies the */
/* name of the SAS format that is to be applied to the node color */
/* variable (DEPTCODE) in order to produce valid HTML color names. */
%ds2tree(ndata=myorg,
archive=treeview.jar,codebase=&codebase,
htmlfile=&htmlfile, cback=white,
nid=empno,
nparent=mgrno,
spread=2.0,
ntip=deptname,
nlabel=name,
ncolor=deptcode, ncolfmt=$nodecol.,
height=500, width=600, cutoff=1.0,
septype=none, center=y, brtitle=SAS TreeView Sample,
ttag=header 2, tcolor=navy,
tface=%str(Arial,Helvetica,sans-serif),
ftag=header 4, fcolor=navy,
fface=%str(Arial,Helvetica,sans-serif));
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
This example creates a Java applet that displays the following organizational chart. This example uses the experimental DS2TREE macro to display information from an employee database and create an HTML file that includes applet parameters and XML statements. These parameters and statements are used to create the TreeView graph. The DS2TREE macro is experimental beginning in Release 8.2 of SAS/GRAPH software and does not run on earlier SAS versions.
To display the department name for any employee on the chart, place your mouse over the name (or node). To move the tree, click a node name and then drag the mouse. Right-click in the chart area to display a pop-up menu with additional options.
| Type: | Sample |
| Topic: | Third Party ==> Programming ==> Java Software Components ==> HTML Formatting Tools |
| Date Modified: | 2006-12-07 13:24:48 |
| Date Created: | 2005-07-08 10:21:42 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | SAS/GRAPH | All | 8.2 TS2M0 | n/a |
| SAS System | SAS/IntrNet | All | 8.2 TS2M0 | n/a |





