nwpreserve

Preserve and restore network data

Syntax

Preserve network data
nwpreserve
    Restore network data
nwrestore

Description

nwpreserve preserves network data by temporarily saving the current network dataset (including all normal Stata variables) in the working directory. Calling nwpreserve again before nwrestore exits with an error (“Already preserved”), as Stata’s own preserve does.

nwrestore restores network data previously preserved (including all Stata variables).

Network types

The command works the same for every network type (see nwnetworktypes).

Examples

Preserve a network, drop it, then restore it:

. nwclear
. nwrandom 5, prob(.4) name(mynet)
. nwpreserve
. nwdrop mynet
. nwset
. nwrestore
. nwset

Also see

  • restore, preserve

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.