Creating Interactive Constellation Diagrams |
The following sample programs generate these kinds of Constellation diagrams:
Constellation Chart with DATATYPE=ARCS |
This sample program generates a very simple Constellation diagram. It displays a number of countries and the languages spoken in those countries.
The following is the Constellation diagram that is generated by the sample code shown below. Notice the help window. Because the diagram is displayed by the Constellation applet, it is not just a static picture. A user can manipulate the diagram, for example, by moving nodes and searching for nodes. The Mouse Help window in the following diagram documents for the user what interactivity is available (right-click a diagram to invoke the window).
The following is the complete SAS code used to generate a Constellation diagram from a SAS data set. Notice the following:
The parameter HTMLFILE= specifies the complete path and name of the HTML file to be created by the DS2CONST macro. If you want to run this sample, then change the value of HTMLFILE to the location where you want the HTML file stored.
The parameter NSHAPE= specifies the variable in the SAS data set that encodes the shape of each node.
The parameter NCOLOR= specifies the variable in the SAS data set that encodes the color of each node.
/*Define a nodes data set of countries and languages */ data nodedata; input nodeLabel $15. shape $10. color $8. size; cards; France square red .1 Germany square red .1 Italy square red .1 Belgium square red .1 Switzerland square red .1 Holland square red .1 German triangle blue .1 French triangle blue .1 Italian triangle blue .1 Flemish triangle blue .1 Dutch triangle blue .1 ; run; /*Define a links data set */ data linkdata; input from $15. to $15.; cards; France French Germany German Belgium French Belgium German Belgium Flemish Belgium Dutch Switzerland French Switzerland German Switzerland Italian Italy Italian Italy German Holland Dutch ; run; goptions reset=all; /* make sure ods listing is open when running macro */ ods listing; /*Run the DS2CONST macro*/ %ds2const(ndata=nodedata, ldata=linkdata, datatype=arcs, cnode=red, colormap=y, height=400, width=500, code=ConstChart, codebase=http://your_path_to_archive, htmlfile=your_path_and_filename.htm, nid=nodelabel, nlabel=nodelabel, lfrom=from, lto=to, fntsize=12, nshape=shape, ncolor=color, nsize=size);
Constellation Chart with DATATYPE=ASSOC |
This sample program generates a very simple Constellation diagram with DATATYPE=ASSOC.
The following is the Constellation diagram that is generated by the sample code. A Constellation diagram with DATATYPE=ASSOC depicts the strength of the relationships among variables. Variables in the SAS data set determine the size and color of nodes, as well as the width and color of the lines between nodes. At the bottom of the picture, notice the slider bar which allows a user to choose how many of the links on the diagram are displayed. Move the slider to the left, and only the most important links are displayed. Move the slider to the right, and all of the links are displayed.
The following is the complete SAS code to generate a Constellation diagram from a SAS data set. Notice the following:
The parameter HTMLFILE= specifies the complete path and name of the HTML file to be created by DS2CONST. If you want to run this sample, then change the value of HTMLFILE to something that makes sense for you.
The parameter NVALUE= specifies the data set variable that is used to determine the size and color of each node.
The parameter LVALUE= specifies the data set variable that is used to determine the width and color of each line between nodes.
data nodedata; length nodeID value 8 label $11 tip $25; input nodeID value @11 label $char11. @25 tip $char25.; cards; 0 6556 depression depression: #6556 1 6322 anxiety anxiety: #6322 2 5980 fatigue fatigue: #5980 3 5286 headache headache: #5286 4 4621 chest pain chest pain: #4621 6 3149 nausea nausea: #3149 ; run; data linkdata; length from to linkvalue 8 tip $40; input from to linkvalue @13 tip $char40.; cards; 2 0 5978 #5978, Support:63.0790, Conf:99.9833 4 1 4621 #4621, Support:48.7602, Conf:100.0000 1 0 4307 #4307, Support:45.4469, Conf:68.1272 1 2 3964 #3964, Support:41.8276, Conf:62.7017 2 3 3010 #3010, Support:31.7611, Conf:50.3429 0 3 3009 #3009, Support:31.7506, Conf:47.5957 1 6 2772 #2772, Support:29.2498, Conf:43.8469 4 6 2609 #2609, Support:27.5298, Conf:56.4596 4 0 2606 #2606, Support:27.4982, Conf:56.3947 4 2 2263 #2263, Support:23.8789, Conf:48.9721 3 0 1980 #1980, Support:20.8927, Conf:40.6821 3 1 1701 #1701, Support:17.9487, Conf:34.9497 3 2 1701 #1701, Support:17.9487, Conf:34.9497 1 3 1593 #1593, Support:16.8091, Conf:25.1977 4 3 1152 #1152, Support:12.1557, Conf:24.9297 0 6 623 #623, Support:6.5738, Conf:9.8545 2 6 623 #623, Support:6.5738, Conf:10.4198 6 3 597 #597, Support:6.2995, Conf:20.0268 3 6 372 #372, Support:3.9253, Conf:7.6433 6 0 344 #344, Support:3.6298, Conf:11.5398 run; /* make sure ods listing is open when running macro */ ods listing; title1 "Diagnosis Sequence Diagram."; %ds2const(ndata=nodedata, ldata=linkdata, datatype=assoc, minlnkwt=30, height=450, width=600, codebase=http://your_path_to_archive, htmlfile=your_path_and_filename.htm, colormap=y, nid=nodeID, nlabel=label, nvalue=value, fntsize=12, ntip=tip, lfrom=from, lto=to, lvalue=linkvalue, ltip=tip, linktype=arrow);
Constellation Chart with XML Written to an External File |
This sample program generates the same Constellation diagram as the previous example,Constellation Chart with DATATYPE=ASSOC, with the difference that the XML is written to an external file instead of being embedded in the HTML file.
The following is the complete SAS code to generate the Constellation diagram from a SAS data set. You can notice the following:
The parameter HTMLFILE= specifies the complete path and name of the HTML file to be created by DS2CONST. 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 DS2CONST macro that the XML that 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.
data nodedata; length nodeID value 8 label $11 tip $25; input nodeID value @11 label $char11. @25 tip $char25.; cards; 0 6556 depression depression: #6556 1 6322 anxiety anxiety: #6322 2 5980 fatigue fatigue: #5980 3 5286 headache headache: #5286 4 4621 chest pain chest pain: #4621 6 3149 nausea nausea: #3149 ; run; data linkdata; length from to linkvalue 8 tip $40; input from to linkvalue @13 tip $char40.; cards; 2 0 5978 #5978, Support:63.0790, Conf:99.9833 4 1 4621 #4621, Support:48.7602, Conf:100.0000 1 0 4307 #4307, Support:45.4469, Conf:68.1272 1 2 3964 #3964, Support:41.8276, Conf:62.7017 2 3 3010 #3010, Support:31.7611, Conf:50.3429 0 3 3009 #3009, Support:31.7506, Conf:47.5957 1 6 2772 #2772, Support:29.2498, Conf:43.8469 4 6 2609 #2609, Support:27.5298, Conf:56.4596 4 0 2606 #2606, Support:27.4982, Conf:56.3947 4 2 2263 #2263, Support:23.8789, Conf:48.9721 3 0 1980 #1980, Support:20.8927, Conf:40.6821 3 1 1701 #1701, Support:17.9487, Conf:34.9497 3 2 1701 #1701, Support:17.9487, Conf:34.9497 1 3 1593 #1593, Support:16.8091, Conf:25.1977 4 3 1152 #1152, Support:12.1557, Conf:24.9297 0 6 623 #623, Support:6.5738, Conf:9.8545 2 6 623 #623, Support:6.5738, Conf:10.4198 6 3 597 #597, Support:6.2995, Conf:20.0268 3 6 372 #372, Support:3.9253, Conf:7.6433 6 0 344 #344, Support:3.6298, Conf:11.5398 run; title1 "Diagnosis Sequence Diagram."; /* make sure ods listing is open when running macro */ ods listing; %ds2const(ndata=nodedata, ldata=linkdata, datatype=assoc, minlnkwt=30, height=450, width=600, codebase=http://your_path_to_archive, htmlfile=your_path_and_filename.htm, xmltype=external, makexml=y, xmlurl=http://www.xyz.com/Web_output/const_assoc_external.xml, xmlfile=u://Web_output/const_assoc_external.xml, colormap=y, nid=nodeID, nlabel=label, nvalue=value, fntsize=12, ntip=tip, lfrom=from, lto=to, lvalue=linkvalue, ltip=tip, linktype=arrow);
Constellation Chart with Hotspots |
This sample program generates the same Constellation diagram as in Constellation Chart with DATATYPE=ARCS and adds hotspots to the nodes of the diagram.
The following is the complete SAS code to generate the Constellation diagram from a SAS data set. Notice the following:
The parameter NURL= specifies the variable in the SAS data set that contains the URL to be linked to when a user double-clicks the node.
/*Define a nodes data set of countries and languages */ data nodedata; input nodeLabel $15. shape $10. color $8. size url $40.; cards; France square red .1 http://www.xyz.com Germany square red .1 http://www.xyz.com/rnd/webgraphs/ Italy square red .1 http://www.xyz.com Belgium square red .1 http://www.xyz.com/rnd/webgraphs/ Switzerland square red .1 http://www.xyz.com Holland square red .1 http://www.xyz.com German triangle blue .1 http://www.xyz.com French triangle blue .1 http://www.xyz.com/rnd/webgraphs/odssyntax.htm Italian triangle blue .1 http://www.xyz.com Flemish triangle blue .1 http://www.xyz.com Dutch triangle blue .1 http://www.xyz.com ; run; /*Define a links data set: */ data linkdata; input from $15. to $15.; cards; France French Germany German Belgium French Belgium German Belgium Flemish Belgium Dutch Switzerland French Switzerland German Switzerland Italian Italy Italian Italy German Holland Dutch ; run; goptions reset=all; /* make sure ods listing is open when running macro */ ods listing; /*Run the DS2CONST macro:*/ %ds2const(ndata=nodedata, ldata=linkdata, nurl=url, datatype=arcs, cnode=red, colormap=y, height=400, width=500, code=ConstChart, codebase=http://your_path_to_archive, htmlfile=your_path_and_filename.htm, nid=nodelabel, nlabel=nodelabel, lfrom=from, lto=to, fntsize=12, nshape=shape, ncolor=color, nsize=size);
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.