Setting decimal points


The default behavior of asdocx is to report three decimal points and suppress trailing zeros. Several controls are available to customize decimal points. I discuss these in the following paragraphs with examples.

Default behavior


asdocx reports three decimal points by default. If the trailing values are all zeros, asdocx will not report them. For example, note min and max column in the following table. Some of the values have no decimal points because these are integers and have no decimal points. The minimum value for headroom is 1.5. If we were to report three decimal points even if the trailing values were zero, this would be reported as 1.500. For doing so, we shall use the tzok option, that is trailing zeros are OK.

* Load example data
sysuse auto, clear

* Default behavior
asdocx sum, replace
Descriptive Statistics
Variable Obs Mean Std. Dev. Min Max
price 74 6165.257 2949.496 3291 15906
mpg 74 21.297 5.786 12 41
rep78 69 3.406 0.99 1 5
headroom 74 2.993 0.846 1.5 5
trunk 74 13.757 4.277 5 23
weight 74 3019.459 777.194 1760 4840
length 74 187.932 22.266 142 233
turn 74 39.649 4.399 31 51
displacement 74 197.297 91.837 79 425
gear_ratio 74 3.015 0.456 2.19 3.89
foreign 74 0.297 0.46 0 1

Report equal number of decimal points


Option tzok is used to report equal number of decimal points even if the trailing values are zero.

* Load example data
sysuse auto, clear

* Trailing zero allowed for all columns
asdocx sum, replace tzok 
Descriptive Statistics
Variable Obs Mean Std. Dev. Min Max
price 74 6165.257 2949.496 3291.000 15906.000
mpg 74 21.297 5.786 12.000 41.000
rep78 69 3.406 0.990 1.000 5.000
headroom 74 2.993 0.846 1.500 5.000
trunk 74 13.757 4.277 5.000 23.000
weight 74 3019.459 777.194 1760.000 4840.000
length 74 187.932 22.266 142.000 233.000
turn 74 39.649 4.399 31.000 51.000
displacement 74 197.297 91.837 79.000 425.000
gear_ratio 74 3.015 0.456 2.190 3.890
foreign 74 0.297 0.460 0.000 1.000

Change decimal points (all columns)


Decimal points for all columns can be changed with the option dec(#), where # is an integer, e.g., dec(2) or dec(4), etc. Suppose we wish to report four decimal points, we shall add option dec(4).

* Load example data
sysuse auto, clear

* Four decimal points for all columns
asdocx sum, replace dec(4) 
Descriptive Statistics
Variable Obs Mean Std. Dev. Min Max
price 74 6165.2568 2949.4959 3291 15906
mpg 74 21.2973 5.7855 12 41
rep78 69 3.4058 0.9899 1 5
headroom 74 2.9932 0.846 1.5 5
trunk 74 13.7568 4.2774 5 23
weight 74 3019.4595 777.1936 1760 4840
length 74 187.9324 22.2663 142 233
turn 74 39.6486 4.3994 31 51
displacement 74 197.2973 91.8372 79 425
gear_ratio 74 3.0149 0.4563 2.19 3.89
foreign 74 0.2973 0.4602 0 1

Different decimal points for specific columns


asdocx provides the flexibility of setting decimal points separately for each column. So if we wish to report 2 decimal points for the third column, and four decimal points for the fourth column, we shall use option c3_dec(2) and c4_dec(4). The prefix c3 and c4 refer to column three and four (please note that the variables column is counted as column one). For easy identification of column numbers, asdocx displays the column number with each table on the Stata screen. Please note that these options are sticky. Their effects linger unless they are changed or Stata is restarted.

* Load example data
sysuse auto, clear

* Custom decimal points for each column
asdocx sum, replace c3_dec(2) c4_dec(4)
Descriptive Statistics
Variable Obs Mean Std. Dev. Min Max
price 74 6165.26 2949.4959 3291 15906
mpg 74 21.3 5.7855 12 41
rep78 69 3.41 0.9899 1 5
headroom 74 2.99 0.846 1.5 5
trunk 74 13.76 4.2774 5 23
weight 74 3019.46 777.1936 1760 4840
length 74 187.93 22.2663 142 233
turn 74 39.65 4.3994 31 51
displacement 74 197.3 91.8372 79 425
gear_ratio 74 3.01 0.4563 2.19 3.89
foreign 74 0.3 0.4602 0 1

Equal number of decimal points for specific columns


Just like decimal points, tzok option can be used with specific columns. If we were to report equal number of decimal points for column 5, we would use c5_tzok.

* Load example data
sysuse auto, clear

* Trailing zeros allowed only for column 5
asdocx sum, replace c5_tzok 
Descriptive Statistics
Variable Obs Mean Std. Dev. Min Max
price 74 6165.257 2949.496 3291.000 15906
mpg 74 21.297 5.786 12.000 41
rep78 69 3.406 0.99 1.000 5
headroom 74 2.993 0.846 1.500 5
trunk 74 13.757 4.277 5.000 23
weight 74 3019.459 777.194 1760.000 4840
length 74 187.932 22.266 142.000 233
turn 74 39.649 4.399 31.000 51
displacement 74 197.297 91.837 79.000 425
gear_ratio 74 3.015 0.456 2.190 3.89
foreign 74 0.297 0.46 0.000 1

Column specific formatting can be combined


We saw in the previous examples that option c#_tzok and c#_dec() target a specific column to format / set the decimal points. The good news is that we can combine these options. Therefore, if we were to report two decimal points and trailing zeros for column 5, we would type c5_dec(2) and c5_tzok.

* Load example data
sysuse auto, clear

* Trailing zeros allowed only for column 5
asdocx sum, replace c5_tzok c5_dec(2)
Descriptive Statistics
Variable Obs Mean Std. Dev. Min Max
price 74 6165.257 2949.496 3291.00 15906
mpg 74 21.297 5.786 12.00 41
rep78 69 3.406 0.99 1.00 5
headroom 74 2.993 0.846 1.50 5
trunk 74 13.757 4.277 5.00 23
weight 74 3019.459 777.194 1760.00 4840
length 74 187.932 22.266 142.00 233
turn 74 39.649 4.399 31.00 51
displacement 74 197.297 91.837 79.00 425
gear_ratio 74 3.015 0.456 2.19 3.89
foreign 74 0.297 0.46 0.00 1