Data visualization with SAS programming

Graphing networks

Reply
Contributor
Posts: 59

Graphing networks

There are many papers on using SAS/Graph to visualize networks of predator-prey food networks. I have a much more specific graph I would like to do in SAS that is summarized in this Science article titled "Asymmetric Coevolutionary Networks." The graph captured in this article has the network laid out in vertical arrays with lines drawn between the nodes to indicate the degree of association. How would I express such a visual relationship in SAS?

Thank you.

http://www.sciencemag.org/content/312/5772/431/F1.expansion.html

Grand Advisor
Posts: 9,748

Re: Graphing networks

Look to see if you have access to the SAS/Grahp Network Visualization Workshop.

I believe you would be looking at a variation on the Fixed Position Network Graph where your Positions file would have on value of x-axis and varying y-axis for each node descriptor.

Contributor
Posts: 59

Re: Graphing networks

Thank you. I do not have this Workshop in my SAS installation. Any other suggestions?

SAS Super FREQ
Posts: 1,044

Re: Graphing networks

Simple network diagrams could be created using SGPLOT or GTL, as long as you can position the nodes.

I described one case here:  http://blogs.sas.com/content/graphicallyspeaking/2014/09/21/splines/

In your case the nodes are in a simple two column arrangement.  In such cases,you could use a Vector plot to draw the links, and overlay that with a Bubble plot to draw the nodes with or without labels.  You can suppress the axes and other outlines.

I will write up a simple case.  What release of SAS (including maintenance level) do you have?

Contributor
Posts: 59

Re: Graphing networks

That would be so helpful! Especially if I can get it to work on my data. Btw, I want to create a network for over 200 medical diagnostic codes to graphically illustrate their co-occurrence in patients over a year's period.

I'm running v9.3 with the TSIM1 maintenance install.

Thank you.

SAS Super FREQ
Posts: 1,044

Re: Graphing networks

Here is a simple example.  The NOBORDER option may not work on SAS 9.3, you can remove it.

To keep it simple, I just hard coded the link coordinates.  However, a better way is to provide the FromNodeId and ToNodeId for the links, create Hash Object for Nodes and extract the link end coordinates from the hash object using the nodeids.  Sorry, I could not attach the resulting image.

Clearly, it does not do the nice layout of the nodes for uslike a Network Diagram statement would, but we are really using the graph code meant for something else to draw diagrams for us.

data diagram;

  input nodeid grp nx ny linkid x1 y1 x2 y2;

  size=10;

  datalines;

1  1  10  10  1  10  10  20   8

2  1  10   8  2  10  10  20   6

3  1  10   6  3  10  6   20  10

4  2  20  10  .  .   .   .    .

5  2  20   8  .  .   .   .    .

6  2  20   6  .  .   .   .    .

;

run;

title 'Network Diagram';

proc sgplot data=diagram noautolegend noborder;

  vector x=x2 y=y2 / xorigin=x1 yorigin=y1;

  bubble x=nx y=ny size=size / group=grp bradiusmin=15 bradiusmax=20;

  xaxis display=none offsetmin=0.2 offsetmax=0.2;

  yaxis display=none offsetmin=0.2 offsetmax=0.2;

run;

Contributor
Posts: 59

Re: Graphing networks

Thank you! That worked despite a Java issue.

Post a Question
Discussion Stats
  • 6 replies
  • 437 views
  • 6 likes
  • 3 in conversation