nwvalidvars
Validate Stata variables for a network
Syntax
nwvalidvars
nodes ,
stub(string)
Description
Validates names of Stata variables that can be used to represent a network of size nodes. Stata variables are generated by combining stub() with a consecutive number. If these Stata variables already exists, the command comes up with a new suggestion for naming variables. This command is mostly used for progamming.
Network types
The command works the same for every network type (see nwnetworktypes).
Limits
One name per node goes into a Stata macro. When the nodes names do not fit into a macro (about 20,000 names in Stata/BE) the command stops at once with r(900) and a message.
Examples
. nwclear
. nwwebuse gang
. nwvalidvars 10, stub(g)
. return list
Stored results
- r(stub) — stub used to generate Stata variable names
- r(valid) — “true” when Stata variables do not already exist, “false” otherwise
- r(validvars) — list of valid Stata variables
Also see
nwcommands version 3.25.0, 14 November 2026 (check your installed version)