Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • One decimal point

    Hello,

    here's my code and I want to see my chi-squared tables with only one decimal point. My STATA is STATA 18, and please let me know if anyone knows the clues. Thank you so much in advance.

    "tab Q15Age_num Studygroup if Q15Age_num != ., nofreq column chi2, cell format %1.1f"

  • #2
    I'd talk about this request as to show one decimal place. In the display 3.14159 there is one decimal point -- the stop or period -- and 5 decimal places. Rounding to 1 decimal place would produce 3.1. In some countries the decimal point is a comma, so 3,14159 or 3,1.

    https://www.open.edu/openlearn/mod/o...68&section=2.1 is one of many places discussing this.

    I don't know an option to do this in tabulate. One thing you could do is download the package tab_chi from SSC and then clone tabchi under another name of your choosing and then hack at the code to add an option or to hard-wire what you want.

    Another option is like this:

    Code:
    . sysuse auto
    (1978 automobile data)
    
    . tab foreign rep78
    
               |                   Repair record 1978
    Car origin |         1          2          3          4          5 |     Total
    -----------+-------------------------------------------------------+----------
      Domestic |         2          8         27          9          2 |        48 
       Foreign |         0          0          3          9          9 |        21 
    -----------+-------------------------------------------------------+----------
         Total |         2          8         30         18         11 |        69 
    
    . qui tab foreign rep78, chi2
    
    . di "Chi-square " %2.1f r(chi2)
    Chi-square 27.3
    You could turn that into your own command or do-file.
    Last edited by Nick Cox; 29 May 2024, 04:00.

    Comment

    Working...
    X