Thanks as always to Kit Baum, a new version of the xcontract 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 xcontract.
The xcontract package is described as below on my website. The new version adds a module freqtop ("frequencies to percentages"), which can extend an existing xcontract resultsset by adding new percentage variables, such as row or column percentages if the resultsset represents a table with rows and columns. It also adds a pformat(format) option specifying a non-default format for percentages, and a ztotal(#) option specifying a (usually missing) value for percents based on zero totals, which may happen with freqtop, though they are not expected to be common with xcontract.
Best wishes
Roger
------------------------------------------------------------------------------------------------
package xcontract from http://www.rogernewsonresources.org.uk/stata16
------------------------------------------------------------------------------------------------
TITLE
xcontract: Create or extend dataset of variable combinations with frequencies and percents
DESCRIPTION/AUTHOR(S)
xcontract is an extended version of contract. It creates an output data set
(or resultsset), with 1 observation per combination of values of the
variables in varlist, and data on the frequencies and percents of those
combinations of values in the existing data set, and, optionally, the
cumulative frequencies and percents of those combinations. If the by()
option is used, then the output data set has one observation per combination
of values of the varlist variables per by-group, and percents are calculated
within each by-group. The output data set created by xcontract may be
listed to the Stata log, or saved to a data frame, or saved to a disk file,
or written to the memory (overwriting any pre-existing data set). freqtop
inputs an existing frequency variable in the current dataset, which is
typically an output dataset made by xcontract. It generates new variables,
in the same dataset, containing the corresponding cumulative frequencies
and/or percents and/or cumulative percents, optionally defined within
user-specified by-groups.
Author: Roger Newson
Distribution-Date: 01March2024
Stata-Version: 16
INSTALLATION FILES (click here to install)
xcontract.ado
xcontract.sthlp
freqtop.ado
freqtop.sthlp
------------------------------------------------------------------------------------------------
(click here to return to the previous screen)
The xcontract package is described as below on my website. The new version adds a module freqtop ("frequencies to percentages"), which can extend an existing xcontract resultsset by adding new percentage variables, such as row or column percentages if the resultsset represents a table with rows and columns. It also adds a pformat(format) option specifying a non-default format for percentages, and a ztotal(#) option specifying a (usually missing) value for percents based on zero totals, which may happen with freqtop, though they are not expected to be common with xcontract.
Best wishes
Roger
------------------------------------------------------------------------------------------------
package xcontract from http://www.rogernewsonresources.org.uk/stata16
------------------------------------------------------------------------------------------------
TITLE
xcontract: Create or extend dataset of variable combinations with frequencies and percents
DESCRIPTION/AUTHOR(S)
xcontract is an extended version of contract. It creates an output data set
(or resultsset), with 1 observation per combination of values of the
variables in varlist, and data on the frequencies and percents of those
combinations of values in the existing data set, and, optionally, the
cumulative frequencies and percents of those combinations. If the by()
option is used, then the output data set has one observation per combination
of values of the varlist variables per by-group, and percents are calculated
within each by-group. The output data set created by xcontract may be
listed to the Stata log, or saved to a data frame, or saved to a disk file,
or written to the memory (overwriting any pre-existing data set). freqtop
inputs an existing frequency variable in the current dataset, which is
typically an output dataset made by xcontract. It generates new variables,
in the same dataset, containing the corresponding cumulative frequencies
and/or percents and/or cumulative percents, optionally defined within
user-specified by-groups.
Author: Roger Newson
Distribution-Date: 01March2024
Stata-Version: 16
INSTALLATION FILES (click here to install)
xcontract.ado
xcontract.sthlp
freqtop.ado
freqtop.sthlp
------------------------------------------------------------------------------------------------
(click here to return to the previous screen)