简体   繁体   中英

Output to Table instead of Graph in Stata

In Stata, is there a way to redirect the data that a command does into a table instead of a graph?

Example: if someone created a normal probability distribution of data with the pnorm var_name command, is there a way to redirect the data so that instead of appearing in a graph, it appears in a table?

Yes and no. It really depends on the command you are using. You should look at the help files first.

For instance, pnorm does not allow that. You can create the data yourself using the formula for pnorm described in the help file, where the cumulative distribution at some point is plotted against the so-called plotting position.

Other Stata commands allow you to generate the points directly. This is the case for kdensity for instance.

To add to @Noobie's answer:

Different commands work in different ways. There's no better short summary.

What you can look out for includes

generate() options that produce new variables. (There is absolute rule that the options have this name, but that or a similar name is the most common single variety.)

Options that allow saving results to new datasets.

Saved results, especially those visible after return list or ereturn list . These can be quite elaborate, eg saving of matrices of counts after tabulate .

More broadly, Stata commands aren't functions! One characteristic of a function, as so named in many languages or programs, is that there is a result, with special cases where the result is void or null. There clearly are statistical programs which in broad terms hinge on calling functions which have results, and what you see displayed is often a side-effect of that. Stata commands don't work like that in the sense that the results of a program can be various. In the case of commands designed just to show something, the "result" may be a display. It's worth noting that Mata, which underlies and underpins Stata, is more recognisably a C-like language, with (eg) many matrix extensions, which is based on functions (and much else).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM