Announcement

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

  • logout nicely formatted tables

    Dear all,

    I want to export table in Excel, but to have nice and funcional table. I have categorical variable lwi, and I tabulate the variable. Also I need wieghted data, therefore I use [iw=rb050] option, where rb050 are cross-sectional weights.

    tab lwi [iw=rb050]
    logout, save(lwi) excel replace: tab lwi [iw=rb050]

    My variable has long value labels, and therefore labels of categories are exported in Excel into several columns. I experimented with fix option, but the results are again not nicely displayed. Also both dec and auto options for decimals remove the decimals, and do not round it, therefore when I put dec(1) option, I get 12.95 rounded to 12.9 instead of 13.0.

    Could anyone please help me get some nice excel table. Btw, I have many tab tables, it will be quite time consuming to arrange them by hand. Please find attached the Excel document.

    Thank you
    Best,
    Aleksandra


    Attached Files

  • #2
    I don't use logout and you don't specify where this is from as it is not an official Stata command. You can install estout from SSC by Ben Jann and see if it solves your issue.

    Code:
    ssc install estout
    estpost tab lwi [iw=rb050]
    esttab using myfile.csv
    There is an option for saving the output as an Excel file (.xls), but there may be some formatting issues that are solved by saving the file as .csv.

    Comment


    • #3
      Thank you very much for your answer. Sorry, I forgot to mention that logout is not stata command.
      http://fmwww.bc.edu/RePEc/bocode/l/logout.html

      Unfortunatelly, it does not solve the issue.

      Thank you anyway.
      Best,
      Aleksandra

      Comment


      • #4
        This works. I guess your issue is how to include long labels in the Excel output.

        Code:
        set seed 2019
        set obs 200
        gen lwi= runiformint(0,1)
        lab def lwi 1 "living in a household with work" ///
        0 "not living in a household with work"
        lab values lwi lwi
        gen rb050= runiformint(1,10)
        estpost tab lwi [iw=rb050]
        esttab using myfile.csv, nonumbers nonotes ///
        mtitle(Frequency) varlab(`e(labels)')

        Comment

        Working...
        X