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)


Back to top

nwcommands is free software under the GNU General Public License, version 3, as are the model packages nwsaom, nwergm, nwdynam and nwrem. Citing and licenses · Get help · GitHub. Issues with the core go to the nwcommands repository; issues with a model package go to that package's own repository.

This site uses Just the Docs, a documentation theme for Jekyll.