Network Action Set
Inputting a Molecular Graph
This section contains PROC CAS code.
Note: For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.
This example shows how to input a molecular graph by specifying a Simplified Molecular Input Line Entry System (SMILES) string in the readGraph or loadGraph action.
The following statements read in a SMILES string, specify adding hydrogen atoms to the molecular graph, and output the resulting links and nodes data tables. These statements do not run any algorithms, but you can use the resulting output as input data for subsequent network actions.
proc cas;
loadactionset "network";
action network.readGraph result=r status=s /
smiles = {smilesStr = "Cc1nc(c[nH]1)N(=O)=O", addHydrogens=true}
outNodes = {name = "NodeSetOut", replace=true}
outLinks = {name = "LinkSetOut", replace=true};
run;
print r.ProblemSummary; run;
action table.fetch / table = "NodeSetOut"; run;
action table.fetch / table = "LinkSetOut"; run;
quit;
The problem summary output from this action is shown in Output 28.18.1.
Output 28.18.1: Problem Summary
| Problem Summary | |
|---|---|
| Number of Nodes | 14 |
| Number of Links | 14 |
| Graph Direction | Undirected |
The output data table NodeSetOut, shown in Output 28.18.2, now contains the nodes of the molecular graph and the node attributes that are associated with each atom.
Output 28.18.2: Nodes Data Table of a Molecular Graph
| Selected Rows from Table NODESETOUT | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| _Index_ | node | weight | atomic_num | atomic_symb | chiral_tag | hybridization | formal_charge | explicit_hs | aromatic |
| 1 | 0 | 12.011 | 6 | C | CHI_UNSPECIFIED | SP3 | 0 | 0 | 0 |
| 2 | 1 | 12.011 | 6 | C | CHI_UNSPECIFIED | SP2 | 0 | 0 | 1 |
| 3 | 2 | 14.007 | 7 | N | CHI_UNSPECIFIED | SP2 | 0 | 0 | 1 |
| 4 | 3 | 12.011 | 6 | C | CHI_UNSPECIFIED | SP2 | 0 | 0 | 1 |
| 5 | 4 | 12.011 | 6 | C | CHI_UNSPECIFIED | SP2 | 0 | 0 | 1 |
| 6 | 5 | 14.007 | 7 | N | CHI_UNSPECIFIED | SP2 | 0 | 0 | 1 |
| 7 | 6 | 14.007 | 7 | N | CHI_UNSPECIFIED | SP2 | 1 | 0 | 0 |
| 8 | 7 | 15.999 | 8 | O | CHI_UNSPECIFIED | SP2 | -1 | 0 | 0 |
| 9 | 8 | 15.999 | 8 | O | CHI_UNSPECIFIED | SP2 | 0 | 0 | 0 |
| 10 | 9 | 1.008 | 1 | H | CHI_UNSPECIFIED | UNSPECIFIED | 0 | 0 | 0 |
| 11 | 10 | 1.008 | 1 | H | CHI_UNSPECIFIED | UNSPECIFIED | 0 | 0 | 0 |
| 12 | 11 | 1.008 | 1 | H | CHI_UNSPECIFIED | UNSPECIFIED | 0 | 0 | 0 |
| 13 | 12 | 1.008 | 1 | H | CHI_UNSPECIFIED | UNSPECIFIED | 0 | 0 | 0 |
| 14 | 13 | 1.008 | 1 | H | CHI_UNSPECIFIED | UNSPECIFIED | 0 | 0 | 0 |
The output data table LinkSetOut, shown in Output 28.18.3, contains the links of the molecular graph and the link attributes that are associated with each bond.
Output 28.18.3: Links Data Table of a Molecular Graph
| Selected Rows from Table LINKSETOUT | |||
|---|---|---|---|
| _Index_ | from | to | bond_type |
| 1 | 0 | 1 | SINGLE |
| 2 | 0 | 9 | SINGLE |
| 3 | 0 | 10 | SINGLE |
| 4 | 0 | 11 | SINGLE |
| 5 | 1 | 2 | AROMATIC |
| 6 | 5 | 1 | AROMATIC |
| 7 | 2 | 3 | AROMATIC |
| 8 | 3 | 4 | AROMATIC |
| 9 | 3 | 6 | SINGLE |
| 10 | 4 | 5 | AROMATIC |
| 11 | 4 | 12 | SINGLE |
| 12 | 5 | 13 | SINGLE |
| 13 | 6 | 7 | SINGLE |
| 14 | 6 | 8 | DOUBLE |
The molecular graph, shown in Figure 21, uses conventional colors to differentiate chemical elements and edge styles to differentiate bond types.
Figure 21: Molecular Graph

You can also load a molecular graph by using the loadGraph action. The following statements demonstrate an alternative way to specify the molecular graph, by providing a SMILES string itself as input:
proc cas;
loadactionset "network";
action network.loadGraph result=rl status=s /
smiles = "c1ccccc1"
outGraphList = {name = "OutGraphList", replace=true};
run;
action table.fetch / table = "OutGraphList"; run;
quit;
The graph identifier and several other pieces of summary information about the in-memory graph are now contained in the output data table OutGraphList, as shown in Output 28.18.4.
Output 28.18.4: Summary Information about the In-Memory Molecular Graph
| Selected Rows from Table OUTGRAPHLIST | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| _Index_ | graph | createTime | loaded | direction | nodes | links | multiLinks | selfLinks | standardizedLabels |
| 1 | 0 | 27FEB2026:14:15:02 | 1 | Undirected | 6 | 6 | 0 | 0 | 1 |
Inputting a Molecular Graph
This section contains Lua code for the analysis in the CASL version of this example, which contains details about the results.
For more information about coding in Lua, see Getting Started with SAS Viya for Lua and SAS Viya: System Programming Guide.
The following statements read in a SMILES string, specify adding hydrogen atoms to the molecular graph, and output the resulting links and nodes data tables. These statements do not run any algorithms, but you can use the resulting output as input data for subsequent network actions.
s:network_readGraph{
smiles = {smilesStr = "Cc1nc(c[nH]1)N(=O)=O", addHydrogens=true},
outNodes = {name = "NodeSetOut", replace=true},
outLinks = {name = "LinkSetOut", replace=true}}
You can also specify a SMILES string as input to the loadGraph action as shown in the following statements:
s:network_loadGraph{
smiles = "c1ccccc1",
outGraphList = {name = "OutGraphList", replace=true}}
Inputting a Molecular Graph
This section contains Python code for the analysis in the CASL version of this example, which contains details about the results.
For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.
The following statements read in a SMILES string, specify adding hydrogen atoms to the molecular graph, and output the resulting links and nodes data tables. These statements do not run any algorithms, but you can use the resulting output as input data for subsequent network actions.
s.network.readGraph(
smiles = {smilesStr:"Cc1nc(c[nH]1)N(=O)=O", addHydrogens:True},
outNodes = {"name":"NodeSetOut", "replace":True},
outLinks = {"name":"LinkSetOut", "replace":True})
You can also specify a SMILES string as input to the loadGraph action as shown in the following statements:
s.network.loadGraph(
smiles = "c1ccccc1",
outGraphList = {"name":"OutGraphList", "replace":True})
Inputting a Molecular Graph
This example is not available for the R programming language.