Hi Marziyeh,
check out the return vector after executing the commands:
. return list
You will find that after executing the command "nwgeodesic" the return vector gets populated with different scalars. For example, you will see "r(avgpath)" which holds the average shortest path length for a particular network. You can refer to such a scalar afterwards and display it.
. di r(avgpath)
Alternatively, you can use this information to populate a variable in your dataset. Here is a little example that does this for the florentine data where you have to networks.
// Load the example data
webnwuse florentine, nwclear
// This command also generates the scalar "r(names)" with the names of all negtworks. You could also use "nwunab" or other commands to get this.
nwset
// Generate a new variable where you want to store the average short path lengths for the networks
gen avgpath = .
local i = 1
// Loop through your networks and populate the i'th observation of variable avgpath with the average path of the i'th network in your list r(names) and increment i
foreach onenet in `r(names)' {
nwgeodesic `onenet', xvars
replace avgpath = `r(avgpath)' in `i'
local i = `i' + 1
}
Notice that this solution to populate the new variable requires that you have at least as many observations in your data as networks. But you can also write some code to check this and, if necessary, increase the number of observations.
nwset
if _N < `r(network)' {