Announcement

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

  • Exporting a Chi2 Table to Excel

    Hi all,

    I am having trouble doing something I am sure is very simple. I have spent several hours trying to figure this out with no luck. I need to export a table from Stata to excel. I've tried everything I can think of --asdoc, esttab, estout, matrices, etc. and I can get nothing to work or even remotely close.

    So, using the dataex sample, I have the following results:


    tab price make if turn>47, chi2 expected

    +--------------------+
    | Key |
    |--------------------|
    | frequency |
    | expected frequency |
    +--------------------+

    | Make and model
    Price | Linc. C.. Linc. M.. Merc. C.. | Total
    -----------+---------------------------------+----------
    5,379 | 0 0 1 | 1
    | 0.3 0.3 0.3 | 1.0
    -----------+---------------------------------+----------
    11,497 | 1 0 0 | 1
    | 0.3 0.3 0.3 | 1.0
    -----------+---------------------------------+----------
    13,594 | 0 1 0 | 1
    | 0.3 0.3 0.3 | 1.0
    -----------+---------------------------------+----------
    Total | 1 1 1 | 3
    | 1.0 1.0 1.0 | 3.0

    Pearson chi2(4) = 6.0000 Pr = 0.199

    Using asdoc, I can't get both the frequency and expected frequency, so it's not helpful.
    asdoc tab price make if turn>47, chi2 expected replace

    Tabulation of price make
    Price Make and model
    Linc. Continental Linc. Mark V Merc. Cougar Total
    5379 0 0 1 1
    11497 1 0 0 1
    13594 0 1 0 1
    Total 1 1 1 3
    Pearson Chi2 = 6.00 Prob = 0.1991
    I would appreciate any leads. I have absolutely no idea of what to try next.

  • #2
    Welcome to Statalist.
    Tabulations and Chi2 test values can be exported to Excel with asdocx, not asdoc.
    Code:
    sysuse auto
    
    asdocx tab price make if turn>47, chi2  replace save(Myfile.xlsx)
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	40.6 KB
ID:	1659965

    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment

    Working...
    X