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.

Examples

. nwclear
. nwwebuse gang
. nwvalidvars 10, stub(g)
. return list

Supported network types

Not applicable - a pure Stata-variable-name bookkeeping utility (finds a collision-free stubN variable-name pattern for a given node count); does not read or depend on any network’s own content, directed/valued/two-mode status, or tie values at all.

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

nwcommands version 3.17.6, 9 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.