svret -- Save returned results to your dataset.
Syntax
svret [classlist] [, long type(type) format(%fmt) keep(returnlist)]
where
classlist is one or more of the following: e, r, s, all,
type can be one of the following: all, scalars, or macros, and
returnlist is a list of returned results currently in memory, e.g., r(N).
Description
svret replaces the dataset in memory with the scalars and macros stored in e(), r(), and s().
Options
long instructs svret to store the results in long form. The default is to store them in wide form.
type(type) specifies which type of returns (scalars or macros) to save. The default is to save results from all classes.
format(%fmt) allows you to specify the formats of the numbers in your table. For example, a format of %7.2f specifies that numbers are to be rounded to two decimal places. See [D] format for details.
keep(returnlist) specifies the variables to be kept from the returned results.
Remarks
LaTeX users can use the user-written command texsave (if installed) to automatically output their results into a LaTeX table. See example 3 below.
Examples
1. Store results from summarize in wide form:
. sysuse auto.dta, clear
. summarize price
. svret all
2. Store results from summarize in long form:
. sysuse auto.dta, clear
. summarize price
. svret r, long format(%8.2fc)
3. Output selected statistics from summarize into a LaTeX table. (This example requires the user-written commands texsave and sortobs to be installed.):
. sysuse auto.dta, clear
. summarize price
. svret r, long format(%8.2fc) keep(r(sd) r(mean) r(min) r(max))
. replace variable = "Standard deviation" if variable == "r(sd)"
. replace variable = "Mean" if variable == "r(mean)"
. replace variable = "Min" if variable == "r(min)"
. replace variable = "Max" if variable == "r(max)"
. rename variable Statistic
. rename contents Value
. sortobs Statistic, values(Mean "Standard deviation" Min Max)
. texsave using "table.tex", title(Price statistics (units in dollars)) > footnote("Data obtained from Stata's built-in auto.dta dataset") size(large) > replace
Author
Julian Reif, University of Chicago
jreif@uchicago.edu
Also see
svmat, savedresults