User-Written Programs for Stata
You can describe and install the programs listed below from within Stata using the 'net' command:
These programs have also been incorporated into Christopher Baum's Statistical Software Components (SSC) repository at Boston College with the package name 'digits', so you can also add them to Stata using the 'ssc' command:
New commands for researching digit preferences
digit (egen extension function)
The digit function is an egen extension function that creates a new variable containing the digit stored at a certain decimal position in an existing variable. This new variable can be tabulated to investigate digit preferences. The decimal position of the digit extracted can be specified, as can the rounding of the existing variable prior to digit extraction. Please read this HTML version of the Stata help file for more information and an example of the use of this function.
- Download the _gdigit.ado Stata ado file.
- Download the digit.hlp Stata help file.
The digituse function was designed to be of assistance when cleaning large volumes of data that has been manually entered using a program or procedure that did not constrain the use of decimal places. It tabulates percentage use of the digits 0-9 in each significant digit of a variable. The number of places to the right of the decimal point can be defined using an option while the number of places to the left of the decimal point is automatically set as required by the maximum value stored in the variable. Please read this HTML version of the Stata help file for more information and an example of the use of this function.
- Download the digituse.ado Stata ado file.
- Download the digituse.hlp Stata help file.
Having identified a digit preference problem using digituse, zerouse allows you to look at a specific problem in more detail and to identify the cases affected by this problem. The zerouse function displays the patterns of zero (or another digit) and non-zero digits in a variable. The range of possible formats can be defined using an option as can the 'zero' digit, and results can be tabulated against a different variable or stored in a new variable for later use. Please read this HTML version of the Stata help file for more information and an example of the use of this function.
- Download the zerouse.ado Stata ado file.
- Download the zerouse.hlp Stata help file.