Dima
Dima

Reputation: 146

Calculate Median after Summarize with detail in Stata

The summarize command creates various scalars in Stata. For instance, one can store the mean or min/max values through gen mean=r(mean)afterwards. It is also possible to get more sophisticated measures via the summarize varname, detailoption. Through this, one also obtains the median in form of the 50% percentile.

My goal is to store the median. Is there a corresponding scalar?

Where can I obtain information on stored scalars after standard operations like summarize? As far as I can see they are not listed in the Stata manuals.

Upvotes: 0

Views: 20893

Answers (2)

Dima
Dima

Reputation: 146

After each command, one can find out where the results are saved through ereturn list or return list.

In the case of summarize varname, detail the median can be obtained through r(p50).

summarize varname, detail
return list
local var_median = r(p50)

Upvotes: 3

user4690969
user4690969

Reputation:

The scalars stored by the summarize command are documented at the end of the output of help summarize and in the "Stored results" section of the Stata manual documentation for the summarize command found in the Stata Base Reference Manual PDF included with your Stata installation. In general, returned results for all commands are found in locations analogous to these.

Upvotes: 1

Related Questions