\Thanks as always to Kit Baum, a new version of the descsave package is now available for download from SSC. In Stata, use the ssc command to do this, or adoupdate if you already have an old version of descsave.
The descsave package is described as below on my website. The new version adds a new option
vallabkeep( all | present | none)
(defaulting to all), specifying whether the descsave resultsset created in memory contains all value labels in the input dataset, only value labels whose names are present in the vallab variable because they belong to variables in the input varlist, or no value labels. The new version also adds a new suboption orphans for the saving() option, specifying that value labels in the output dataset (as specified by the vallabkeep() option) will be saved to the dataset saved to a disk file. These new options will be useful if the user later inputs the descsave resultsset into the SSC package invdesc, which modifies variable attributes (including value labels) in the current data frame to those stored in a descsave or describe resultsset in a frame.
Best wishes
Roger
---------------------------------------------------------------------------------------------
package descsave from http://www.rogernewsonresources.org.uk/stata16
---------------------------------------------------------------------------------------------
TITLE
descsave: Save descriptive attributes of variables to a do-file and/or a Stata dataset
DESCRIPTION/AUTHOR(S)
descsave is an extended version of describe, which lists descriptive
attributes for a list of variables in a dataset given by varlist, or for all
variables in the dataset if varlist is not specified. The dataset is the
current dataset in memory, unless using is used to specify a dataset in a
file. The descriptive attributes are variable names, storage types, display
formats, value labels and variable labels (as output by describe), and also
(optionally) a list of characteristics specified by the charlist() option.
descsave creates an output Stata dataset (or resultsset) with one observation
per variable and data on these descriptive attributes. This dataset may be
listed using the list() option and/or saved to a data frame using the frame()
option and/or saved to a file using the saving() option and/or written to the
memory using the norestore or fast option, overwriting any existing dataset.
The file specified by dofile() is a do-file, containing commands which can be
run to reconstruct the descriptive attributes of the variables, assuming that
variables of the same names have been created and are numeric or character as
appropriate. descsave can be used together with export delimited to create a
definitive generic spreadsheet version of the current dataset, together with
a Stata do-file to reconstruct the descriptive attributes of the variables
after the spreadsheet has been input using import delimited.
Author: Roger Newson
Date: 11 March 2021
Stata version: 16
INSTALLATION FILES (click here to install)
descsave.ado
descsave.sthlp
---------------------------------------------------------------------------------------------
(click here to return to the previous screen)