![]() | ![]() | ![]() | ![]() | ![]() |
This example shows you how to generate an advanced hierarchical tree graphic by using the Treeview HTML Generator. The following steps explain the process of creating the graphic:
Use the following code to construct a SAS format. This format creates a variable, COLOR, that is used to control the node color.
filename htmlout "full path location to html file.html";
%let codebase=directory where TREEVIEW.JAR file is located;
proc format;
value color 278='0x5E528B'
480='0xFEC961'
822='0xB97F32'
1094='0x5E528B'
1127='0x7F5934'
1274='0x99341C'
1685='0x8AA5CA'
1779='0x6F7500'
1784='0x8DA742'
1800='0xD7C76E'
1994='0x348E67'
5529='0xC9573C'
6152='0x6173AA';
run;
quit;
The following statements require user input:
FILENAME HTMLOUT, which specifies the location where you want to store the HTML file. Change this statement so that full path location to 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 directory where treeview.jar is located specifies the location of the treeview.jar file.
Use the following code to generate a data set that contains the parent/child relationships:
data employees;
length empno mgrno2 8 level $1 name2 $15 room $5 phone 8
color $8 url $25 tip $200;
input empno mgrno2 @25 level $1. name2 $ room $ phone;
color=put(mgrno2, color.);
url='http://support.sas.com/';
tip=compress(name2) || ' ' || compress(room) || ' x' ||
compress(put(phone, 4.));
cards;
1094 0278 1 Shannon R2233 8496
4797 0480 Bob R2118 7008
9983 0480 Eric R2228 9982
6493 0480 Bruce R2214 5939
2668 0480 William R2230 2160
2658 0480 Ed R2124 6927
1743 0480 Susan R2227 4297
1917 0480 Tressa R2414 3169
1782 0480 Doug R2418 4979
1605 0480 Jeff R2234 6656
1685 0822 2 Erin R2410 1931
6152 0822 2 Tracy R2112 2387
2259 0822 Kenneth R2125 5339
1538 0822 Anna R2114 6718
1211 0822 Harriet R2231 5702
5529 1094 2 Tara R2225 9719
2068 1094 Amy R2232 7261
1994 1094 2 Katie R3456 8992
0480 1094 2 Cara R2238 7676
1127 1094 2 Jim R2242 2650
0822 1094 2 Ryan R2126 8823
1779 1094 2 Lucy R2108 1276
0255 1094 Pam R2132 5855
5057 1127 David R2252 8722
5006 1127 Kerry R2237 7578
2564 1127 Dave R2244 4498
5507 1127 Timothy R2254 3452
3488 1127 Scott R2422 9036
1948 1127 Kathleen R2222 8258
1929 1127 Lisa R2416 7701
0227 1127 Valerie R2224 2836
6551 1127 David R2229 1660
5066 1127 Paul R2246 3121
3240 1127 Allen R2248 2912
4144 1127 Jim R2220 8966
1884 1127 Joseph R2250 9722
1889 1127 Nicole R2256 9104
2669 1127 Dan R2210 7242
3189 1274 Bill R3464 7952
9119 1274 Robert R3468 6808
2235 1274 Jason R3467 6652
1350 1274 Stuart R3448 7110
2786 1274 Cindy R3460 9878
1361 1274 Dawn R5340 3464
1919 1274 Tina R3469 1147
5802 1274 Laura R3455 6878
5018 1274 Heather R3472 4954
2211 1274 Sherri R3470 3558
3313 1274 Robert R3340 1131
0332 1274 Judy R3450 3320
1335 1274 Linda R3466 7610
5130 1685 John R2413 6503
1140 1685 Jim R2417 2481
1681 1685 Jeff R2415 2454
5376 1685 Terry R2411 5348
2223 1685 Jonathan R2421 9955
1156 1779 Zachary R2216 7483
3317 1779 Matthew R2420 3847
3293 1779 Sheila R2102 3981
3202 1779 Patrick R2106 4936
2664 1779 Le R2104 2238
4918 1779 Richard R2116 4336
2264 1779 Ron R2218 2271
0260 1779 Jeff R2425 1288
1096 1779 Art R2212 3706
2554 1784 Jean R3304 4599
3063 1784 Mark R3446 4693
4451 1784 Ed R1237 1289
3005 1784 Elizabeth R3444 4327
8577 1784 Jeff R3308 7517
2262 1784 Howard R3312 6890
4468 1784 Steve R3459 1485
3316 1784 Alan R3452 2070
3142 1784 Sean R3306 7173
9176 1800 Sue R4478 5849
1966 1800 Debra R3336 1143
5666 1800 Alice R3320 8984
1914 1800 Ceci R3454 4796
1334 1800 Beth R3338 6183
1800 1994 2 Sam R3438 7010
3299 1994 Jean R3462 2519
1784 1994 2 Donna R3442 6917
1274 1994 2 Matt R3458 4259
9215 5529 Brennan R2226 3921
7083 5529 Jim R2223 1743
4433 5529 Lee R2219 2584
7113 6152 Melisa R2121 3181
1533 6152 Kelly R2123 3522
7114 6152 Kristin R2117 7600
5368 6152 Kevin R2235 8794
2734 6152 Joe R2221 3132
;
run;
The following variables are among those that were defined in this sample code:
TIP, which defines the information or alternative text (floating tool tip) that is displayed when you hold the mouse over a node in the Treeview.
URL, which defines the URL that is accessed when you double-click a node or when you right-click a node and select Open URL.
COLOR, which defines the node color. In this example, the color of the node depends on the value of the manager number (MGRN02).
Use the following code to issue TITLE and FOOTNOTE statements and run the DS2TREE macro that builds the graphic:
title 'Sales Division Staff';
footnote 'This display uses the Java Treeview applet and DS2TREE.';
%ds2tree(ndata=employees,
archive=treeview.jar, codebase=&codebase,
htmlfref=htmlout, cback=white,
nid=empno,
nparent=mgrno2,
nurl=url,
spread=2,
ntip=tip,
nlabel=name2,
ncolor=color,
height=550, width=800, cutoff=0.8,
septype=none, center=y,
catext=#F2F2DF,
ttag=header 1, tcolor=navy, tsize=+2,
tface=%str(Arial,Helvetica,sans-serif),
ftag=no formatting, fcolor=navy, fsize=+1,
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=TIP and NLABEL=NAME2, 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=COLOR, which specifies the name of the variable in the data set to be used for the node colors.
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.
filename htmlout "full path location to html file.html";
%let codebase=directory where TREEVIEW.JAR file is located;
proc format;
value color 278='0x5E528B'
480='0xFEC961'
822='0xB97F32'
1094='0x5E528B'
1127='0x7F5934'
1274='0x99341C'
1685='0x8AA5CA'
1779='0x6F7500'
1784='0x8DA742'
1800='0xD7C76E'
1994='0x348E67'
5529='0xC9573C'
6152='0x6173AA';
run;
quit;
/* The variable TIP defines the information that is displayed when you hover */
/* over a node in the treeview. */
/* The variable URL defines the URL to go to when you double click on a node */
/* or right click on a node and select OPEN URL. */
/* The variable COLOR defines the node color. */
data employees;
length empno mgrno2 8 level $1 name2 $15 room $5 phone 8 color $8
url $25 tip $200;
input empno mgrno2 @25 level $1. name2 $ room $ phone;
color=put(mgrno2, color.);
url='http://www.sas.com/';
tip=compress(name2) || ' ' || compress(room) || ' x' ||
compress(put(phone, 4.));
cards;
1094 0278 1 Shannon R2233 8496
4797 0480 Bob R2118 7008
9983 0480 Eric R2228 9982
6493 0480 Bruce R2214 5939
2668 0480 William R2230 2160
2658 0480 Ed R2124 6927
1743 0480 Susan R2227 4297
1917 0480 Tressa R2414 3169
1782 0480 Doug R2418 4979
1605 0480 Jeff R2234 6656
1685 0822 2 Erin R2410 1931
6152 0822 2 Tracy R2112 2387
2259 0822 Kenneth R2125 5339
1538 0822 Anna R2114 6718
1211 0822 Harriet R2231 5702
5529 1094 2 Tara R2225 9719
2068 1094 Amy R2232 7261
1994 1094 2 Katie R3456 8992
0480 1094 2 Cara R2238 7676
1127 1094 2 Jim R2242 2650
0822 1094 2 Ryan R2126 8823
1779 1094 2 Lucy R2108 1276
0255 1094 Pam R2132 5855
5057 1127 David R2252 8722
5006 1127 Kerry R2237 7578
2564 1127 Dave R2244 4498
5507 1127 Timothy R2254 3452
3488 1127 Scott R2422 9036
1948 1127 Kathleen R2222 8258
1929 1127 Lisa R2416 7701
0227 1127 Valerie R2224 2836
6551 1127 David R2229 1660
5066 1127 Paul R2246 3121
3240 1127 Allen R2248 2912
4144 1127 Jim R2220 8966
1884 1127 Joseph R2250 9722
1889 1127 Nicole R2256 9104
2669 1127 Dan R2210 7242
3189 1274 Bill R3464 7952
9119 1274 Robert R3468 6808
2235 1274 Jason R3467 6652
1350 1274 Stuart R3448 7110
2786 1274 Cindy R3460 9878
1361 1274 Dawn R5340 3464
1919 1274 Tina R3469 1147
5802 1274 Laura R3455 6878
5018 1274 Heather R3472 4954
2211 1274 Sherri R3470 3558
3313 1274 Robert R3340 1131
0332 1274 Judy R3450 3320
1335 1274 Linda R3466 7610
5130 1685 John R2413 6503
1140 1685 Jim R2417 2481
1681 1685 Jeff R2415 2454
5376 1685 Terry R2411 5348
2223 1685 Jonathan R2421 9955
1156 1779 Zachary R2216 7483
3317 1779 Matthew R2420 3847
3293 1779 Sheila R2102 3981
3202 1779 Patrick R2106 4936
2664 1779 Le R2104 2238
4918 1779 Richard R2116 4336
2264 1779 Ron R2218 2271
0260 1779 Jeff R2425 1288
1096 1779 Art R2212 3706
2554 1784 Jean R3304 4599
3063 1784 Mark R3446 4693
4451 1784 Ed R1237 1289
3005 1784 Elizabeth R3444 4327
8577 1784 Jeff R3308 7517
2262 1784 Howard R3312 6890
4468 1784 Steve R3459 1485
3316 1784 Alan R3452 2070
3142 1784 Sean R3306 7173
9176 1800 Sue R4478 5849
1966 1800 Debra R3336 1143
5666 1800 Alice R3320 8984
1914 1800 Ceci R3454 4796
1334 1800 Beth R3338 6183
1800 1994 2 Sam R3438 7010
3299 1994 Jean R3462 2519
1784 1994 2 Donna R3442 6917
1274 1994 2 Matt R3458 4259
9215 5529 Brennan R2226 3921
7083 5529 Jim R2223 1743
4433 5529 Lee R2219 2584
7113 6152 Melisa R2121 3181
1533 6152 Kelly R2123 3522
7114 6152 Kristin R2117 7600
5368 6152 Kevin R2235 8794
2734 6152 Joe R2221 3132
;
run;
title 'Sales Division Staff';
footnote 'This display uses the Java Treeview applet and DS2TREE.';
/* NID=EMPNO and NPARENT=MGRNO2 specify the names of the variables in the */
/* data set that represent the child and parent nodes, respectively. */
/* NTIP=TIP and NLABEL=NAME2 specify the names of the variables in */
/* the data set to be used for the floating tool tips and the node names, */
/* respectively. */
/* NCOLOR=COLOR specifies the name of the variable in the data set */
/* to be used for the node colors. */
/* The DS2TREE macro creates the HTML and XML. */
%ds2tree(ndata=employees,
archive=treeview.jar, codebase=&codebase,
htmlfref=htmlout, cback=white,
nid=empno,
nparent=mgrno2,
nurl=url,
spread=2,
ntip=tip,
nlabel=name2,
ncolor=color,
height=550, width=800, cutoff=0.8,
septype=none, center=y,
catext=#F2F2DF,
ttag=header 1, tcolor=navy, tsize=+2,
tface=%str(Arial,Helvetica,sans-serif),
ftag=no formatting, fcolor=navy, fsize=+1,
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 TreeView graph. This example uses the experimental treeview.jar file to create an HTML file. The HTML file includes applet parameters and XML statements for the TreeView graph. This applet is experimental in Release 8.2 of SAS/GRAPH software and does not run on earlier SAS versions.
To display additional information for any employee on the chart, place your mouse over the employee name (or node). To move the tree, click and drag a node. Right-click in the chart area to display a pop-up menu with additional options. Right-click a node to display the node-specific functions.
| Type: | Sample |
| Topic: | Third Party ==> Programming ==> Java Software Components ==> HTML Formatting Tools |
| Date Modified: | 2006-12-05 03:02:53 |
| Date Created: | 2005-07-08 10:33:32 |
| 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 |





