help for distplot7

Distribution function plots distplot7 varname [weight] [if exp] [in range] [, surv graph_options by(byvar) freq generate(newvar) mono missing ]

distplot7 varlist [weight] [if exp] [in range] [, surv graph_options freq mono ]


distplot7 produces a plot of the cumulative distribution function(s) for the variables in varlist. This shows the proportion (or if desired the frequency) of values less than or equal to each value.

With the surv option, distplot7 produces a plot of the survival (a.k.a. survivor, reliability, complementary or reverse distribution) function for each varname. This shows the proportion (or if desired the frequency) of values greater than each value, that is, the complement of the cumulative distribution function.

fweights and aweights are allowed.

distplot7 is a renamed clone of distplot 1.6.1 which is for Stata 7. Stata 8 users should use distplot 2.0.0 or later.


surv specifies calculation and graphing of the survival function rather than the distribution function.

graph_options are options allowed with graph, twoway.

Note that with by() each function is treated graphically as if it were a separate variable, so long as the number of groups is not greater than the limit in Stata on the number of y variables on a scatter plot (20 in Stata 7.0).

With more groups, all functions must be treated graphically as a single variable, by using the mono option, which enforces a monochrome treatment. The only connect() line style appropriate is then c(L), and only one pen() and point symbol() may be used.

If ylog is specified, zero values of the survival function are automatically suppressed.

by(byvar) specifies that calculations are to be carried out separately for each class defined by byvar. Any graph will, however, show the functions for all classes. For a graph with separate panels for each class, use the generate() option and then graph newvar varname, by(byvar). by() is only allowed with a single varname.

freq specifies calculation of frequency rather than probability.

generate(newvar) specifies a new variable in which the function will be stored. generate() is only allowed with a single varname.

mono specifies a monochrome treatment, with a single pen() colour, connect() style and point symbol(). See above, under graph_options.

missing, used only with by(), permits the use of non-missing values of varname corresponding to missing values for the variable named by by(). The default is to ignore such values.


. distplot7 mpg

. distplot7 mpg, by(foreign) c(ll)

. distplot7 mpg, by(foreign) c(JJ) surv

. distplot7 length width height


Nicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk


Elizabeth Allred made helpful comments during program development. Roger Harbord identified a limitation and pointed to a way to resolve it.

Also see

On-line: help for graph, cumul, quantile, quantil2 (if installed) Manual: [R] graph, [R] cumul, [R] diagplots