help for spec_stand                                                 (Rosa Gini)

Create dataset of stratum-specific, unadjusted and standardized rates

spec_stand num denom stratavars [if exp] [in range], by(groupvars) using(filename) namepopstd(varname) [ standonly speconly unadjusted saving(filename[,replace]) norestore format(%fmt) level(#) constant(#) ratename(newvarname) lbname(newvarname) ubname(newvarname) dentot(newvarname) numtot(newvarname)]


spec_stand creates an output dataset of rates (resultsset) for num in the population defined by pop, across the strata defined by stratavars, in order to obtain a comparison across groups identified by groupvars. Both stratum-specific and standardized rates are computed, the last being defined as a weighted averages of the stratum-specific rates. The standard population providing weights for every single stratum must be specified in a separate file. As an option, unadjusted rates can be computed as well. Standardized rates are computed via the dstdize command, while stratum-specific and unadjusted rates are provided by the cii command, with the exact option for confidence intervals.

The output data set created by spec_stand may be saved to a disk file or written to the memory (overwriting any pre-existing data set).

num is the variable name for the study population's number of cases. It must contain integers and each subpopulation identified by groupvars must have the same values or missing.

den identifies the number of subjects represented by each observation in the study population.

stratavars define the strata, e.g. age bands and/or sex.


by(groupvars) is not optional for the spec_stand command; it specifies the variables identifying the study populations, across wish rate comparisons are to be made. If you do not have a variable for this option, you can generate one by typing "gen new=1" and then specifying by(new).

using(filename) must be used to specify the standard population for the spec_stand command. The file filename must be a Stata dataset, containing the variables stratavars and the variable specified in the namepopstd option. The variables stratavars might not uniquely identify an observation in the dataset: if this is the case, the dataset will be contracted.

namepopstd(varname) is the variable containing the number of subjects in each stratum and contained in the dataset specified by the using option. The variables stratavars might not uniquely identify an observation in the dataset: if this is the case, the dataset will be contracted and the variable identified by the namepopstd option will be summed up across strata. Keep in mind that only records with non-missing stratavars will contribute to form the standard population.

standonly or speconly specify that only stardarized, or, respectively, only stratum-specific rates are to be computed and included in the final dataset.

unadjusted, only available if the speconly option is not specified, provides also unadjusted rates.

saving(filename[,replace]) saves the output data set to a disk file. If replace is specified, and a file of that name already exists, then the old file is overwritten.

norestore specifies that the output data set will be written to the memory, overwriting any pre-existing data set. Otherwise, if norestore is not specified, then the pre-existing data set is restored in the memory after the execution of spec_stand. Either this option or the saving() option should be specified.

format(%fmt) specifies the format in which to store the computed rates and confidence intervals. The default is %5.1f.

level(#) specifies the confidence level, in percent, for the confidence interval of the rates; see help level.

constant(#), a multiplicative constant for wich all rates are multiplied. Default is 100.

ratename(newvarname), lbname(newvarname), ubname(newvarname) specify names for variables containing rates and lower and upper limits for confidence intervals. Defaults are _rate, _lb and _ub.

dentot(newvarname) and numtot(newvarname) specify names for variables containing total denominators and numerators in the same group. Defaults are _den_tot and _num_tot.


. spec_stand num den age_band sex,by(state year) using(standard.dta) namepopstd(population) const(1000) norest

. use standard_pop.dta,clear . egen age_band=cut(age),at(65,75,85,150) . tempfile standard . save `standard' . use indicators.dta,clear . spec_stand num den age_band ,by(state year) using(`standard') namepopstd(population) standonly saving(computed.dta,replace) rate(rate) low(l) up(u) dentot(den_tot) numtot(num_tot)