Sample Programs: Treeview Macro


The following sample programs generate Treeview diagrams:

  • Sample Treeview with XML Embedded in the HTML File on page 507

  • Sample Treeview with XML Written to an External File on page 509

  • Treeview with Hotspots on page 510.

Sample Treeview with XML Embedded in the HTML File

This sample program generates a very simple Treeview diagram.

Results Shown in a Browser

The following is the Treeview diagram that is generated by the sample code. Notice the pop-up menu. Because the diagram is displayed by the Treeview applet, it is not just a static picture. A user can manipulate the diagram, for example, by bringing selected nodes to the center, spreading out the nodes, and searching for nodes.

click to expand

SAS Code

The following is the complete SAS code used to generate the Treeview diagram from a SAS data set. Note the following:

  • The parameter HTMLFILE= specifies the complete path and name of the HTML file to be created by the DS2TREE macro. If you want to run this sample, then change the values of HTMLFILE and CODEBASE to the locations that you want to use.

  • The parameter XMLTYPE =INLINE tells the DS2TREE macro that the XML it generates from the SAS data set should be included inline in the HTML file.

  • The parameter CUTOFF=1 specifies that every node on the graph be labeled. Use this parameter to suppress node labels for diagrams with numerous nodes.

 data father_and_sons;  input id . name . father .;  cards;  aaron   Aaron Parker  bob     Bob Parker     aaron  charlie Charlie Parker aaron  david   David Parker   aaron  edward  Edward Parker  david  ;  run;  /* make sure ods listing is open when running macro */  ods listing;   /* run the macro */  %ds2tree(ndata=father_and_sons, /* data set */           /* specify complete url if jar files are not in same directory as html file */           codebase=http://  your_path_to_archive  ,           xmltype=inline,           htmlfile=  your_path_and_filename  .htm,           nid=id,        /* use this variable as the id */           cutoff=1,      /* display the name on every node */           nparent=father,/* this identifies the parent of each node */           nlabel=name,   /* display this on each node */           height=400,           width=400,           tcolor=navy,           fcolor=black); 

Sample Treeview with XML Written to an External File

This sample program generates the same Treeview as the previous example, Sample Treeview with XML Embedded in the HTML File on page 507, with the difference that the XML is written to an external file instead of being embedded in the HTML file.

SAS Code

The following is the complete SAS code to generate the Treeview diagram from a SAS data set. Note the following:

  • The parameter HTMLFILE= specifies the complete path and name of the HTML file to be created by the DS2TREE macro. If you want to run this sample, then change the value of HTMLFILE to something that makes sense for you.

  • The parameter XMLTYPE=EXTERNAL tells the DS2TREE that the XML it generates from the SAS data set should be written to an external file.

  • The parameter XMLFILE= specifies the path and file name of the XML file to be created.

  • The parameter XMLURL= specifies how the XML file is to be addressed from within the HTML file.

  • The parameter CUTOFF=1 specifies that every node on the graph be labeled. Use this parameter with a value between 0 and 1 to suppress node labels for diagrams with numerous nodes.

 data father_and_sons;  input id . name . father .;  cards;  aaron   Aaron Parker  bob     Bob Parker     aaron  charlie Charlie Parker aaron  david   David Parker   aaron  edward  Edward Parker  david  ;  run;  goptions reset=all;  /* make sure ods listing is open when running macro */  ods listing;   /* run the macro */  %ds2tree(ndata=father_and_sons, /* data set */           codebase=http://  your_path_to_archive  ,           htmlfile=  your_path_and_filename  .htm,           xmltype=external,           makexml=y,           xmlurl=htp://www.xtz.com/weboutput_treeview2_sample.xml,           xmlfile=u:/public/weboutput_treeview2_sample.xml,           nid=id,        /* as the id, use this variable specified here */           cutoff=1,      /* display the name on every node */           nparent=father,/* this identifies the parent of each node */           nlabel=name,   /* displ  ay the value of this variable on each node */           height=400,           width=400,           tcolor=navy,           fcolor=black); 

Treeview with Hotspots

This sample program generates the same Treeview as the previous example, Sample Treeview with XML Embedded in the HTML File on page 507, with the difference that a node is associated with a URL and can be activated by a user double-clicking the node.

SAS Code

The following is the complete SAS code to generate the Treeview diagram from a SAS data set. Note the following:

  • The parameter NURL= specifies that the URL to be opened when the corresponding node is double-clicked.

  • The parameter DRILTARG=_TOP specifies that the HTML file is to be opened in the same window as the Treeview diagram instead of in a new window, as is the default.

 data father_and_sons;  input id . name . father . url .;  cards;  aaron   Aaron Parker           http://www.xyz.com/index.html  bob     Bob Parker     aaron   http://www.xyz.com/index.html  charlie Charlie Parker aaron   http://www.xyz.com/index.html  david   David Parker   aaron   http://www.xyz.com/index.html  edward  Edward Parker  david   http://www.xyz.com/index.html  ;  run;  /* make sure ods listing is open when running macro */  ods listing;  /* run the macro */  %ds2tree(ndata=father_and_sons, /* data set */           /* specify complete url if jar files are not in same directory as html file */           codebase=http://  your_path_to_archive  ,           xmltype=inline,           htmlfile=  your_path_and_filename  .htm,           nid=id,        /* as the id, use the variable specified here */           cutoff=1,      /* display the name on every node */           nparent=father,/* this identifies the parent of each node */           nlabel=name,   /* display the value of this variable on each node */           height=400,           width=400,           tcolor=navy,           fcolor=black,           nurl=url,           driltarg=_top ); 



SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net