Announcement

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

  • Exporting results of tabm to latex

    Hi all,

    I am using tabm from the tab-chi module (ssc) to tabulate multiple variables with the same values. What I want to understand is how to export these results to latex as tabm does not work with estpost. Is there a way to make it work. Alternatively, is there any other way to tab frequency tables of multiple variables in a way that is compatible with latex?

    Here is what my data looks like

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(skipped_reading rushed_question prompt_answer pauses repeat_question noprobe options_read options_no_read)
    2 2 1 1 1 1 1 1
    1 2 1 3 2 1 1 1
    1 1 1 1 1 1 1 1
    1 1 1 1 1 1 1 1
    1 1 1 3 2 1 1 1
    1 2 1 1 3 1 1 1
    1 2 2 1 1 2 1 1
    4 1 1 2 4 2 2 1
    1 1 1 1 1 2 1 1
    1 1 2 2 2 3 2 1
    1 1 1 1 2 3 1 1
    1 1 1 2 3 1 1 1
    2 1 2 1 1 2 1 1
    3 1 1 1 2 3 1 1
    1 2 3 2 2 2 1 1
    1 2 2 1 2 2 1 1
    2 1 1 1 2 4 2 1
    1 1 1 1 3 1 1 1
    1 1 1 1 1 1 1 1
    1 1 1 1 1 2 1 1
    2 1 1 2 4 4 1 1
    1 2 1 1 1 2 1 1
    1 2 1 1 2 1 1 1
    1 1 1 1 2 2 1 1
    1 1 1 2 2 2 1 1
    end
    Thanks in advance!

  • #2
    I'm not familiar with tabm so you may want to provide more information about what you're trying to do with it that isn't included in tabulate.

    However, estpost and estout may provide the functionality you're looking for (installation here, documentation here).

    For example:

    Code:
    sysuse auto, clear 
     estpost tabulate foreign  
     esttab . using "outputfile.tex", cells("b pct(fmt(2)) cumpct(fmt(2))") noobs

    Comment


    • #3
      Hi Arthur,

      Thanks for the response. I am familiar with estpost and esttab. However, the table that I want is a frequency table of different variables that have values over the same range. If you see my data example, I have 8 variables taking values from 1-4. I want a table that has the variables in the rows and 1-4 in the columns, and each cell shows me the frequency of that variable for that value. This cannot be done with tabulate (even the two-way version), but can easily be done with tabm. However, the issue is that tabm is not working with estpost, which is why I am looking for either a hack to make it work with estpost or use some other way to plot the table I want.

      This is what the tabm command and the output looks like

      Code:
      tabm skipped_reading_sup rushed_question_sup prompt_answer_sup pauses_sup repeat_question_sup noprobe_sup options_read_sup options_no_read_sup
      
      
                            |                   values
                   variable |     Never  Rarely /   Sometimes      Often |     Total
      ----------------------+--------------------------------------------+----------
      Surveyor skipped read |       175         28          6          3 |       212 
      Surveyor rushed throu |       157         48          6          1 |       212 
      Surveyor prompted ans |       144         65          3          0 |       212 
      Surveyor took long pa |       155         46         10          1 |       212 
      Surveyor repeated que |       119         70         20          3 |       212 
      Surveyor did not prob |        95         95         15          7 |       212 
      Surveyor read options |       209          3          0          0 |       212 
      Surveyor did not read |       210          2          0          0 |       212 
      ----------------------+--------------------------------------------+----------
                      Total |     1,264        357         60         15 |     1,696

      Comment


      • #4
        I am familiar with tabm which is from tab_chi (not tab-chi) on SSC. However, I haven't tried to use it with estpost or esttab (most up-to-date version on SSC as Arthur Morris documents, as it was not done in #1). estout is an outstanding package I never use.

        Among various possibilities (you don't explain what "doesn't work" in #1; see comments in FAQ Advice #12 on this wording) you might note the replace option of tabm after which the implication of #2 is that estout is compatible with tabulate.

        Comment


        • #5
          Thanks Nick! Using the replace option helped, and after that I could use tabulate to show the same result.

          Comment


          • #6
            Originally posted by Akash Bhatt View Post
            Thanks Nick! Using the replace option helped, and after that I could use tabulate to show the same result.
            If you found a way to answer your original question, please share for those who have this question in the future!

            Comment


            • #7
              Originally posted by Akash Bhatt View Post
              Thanks Nick! Using the replace option helped, and after that I could use tabulate to show the same result.
              I am trying with the following

              preserve
              tabm varlist, replace
              estpost tab _stack _values
              esttab, cell("b pct(fmt(a))") collab("Freq." "Percent") noobs nonumb nomtitle tex
              restore

              but this is not working.
              While the tabm does its job in providing one single table, when I switch to "estpost tab _stack _values" the output exported provides multible tables (one for each value).

              Akash Bhatt would you mind sharing your solution? or anybody else who understood how to combine "tabm, replace" with "tabulate" to then export the table in latex.

              Thanks!
              Last edited by Lorenzo Bombino; 19 Jun 2023, 03:47.

              Comment


              • #8
                asdocx offers a variety of tools to export tables created from tabulation of categorical variables. The tables can be exported to Word, Excel, LaTeX, or HTML. Here is a few links to explore:

                tabmany – Table of multiple coded answers
                mrtab – One- and two-way tables of multiple responses
                tabcount – tabulates frequencies for up to 7 variables
                tab3way – Three way table of frequencies and percentages
                missings – Various utilities for managing missing values
                tabulate, tab1, tab2
                pctab – report percentages in cross-tabulations
                crosstab - Tabulation with weighted means, percentages, etc.
                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


                • #9
                  Originally posted by Lorenzo Bombino View Post

                  I am trying with the following

                  preserve
                  tabm varlist, replace
                  estpost tab _stack _values
                  esttab, cell("b pct(fmt(a))") collab("Freq." "Percent") noobs nonumb nomtitle tex
                  restore

                  but this is not working.
                  While the tabm does its job in providing one single table, when I switch to "estpost tab _stack _values" the output exported provides multible tables (one for each value).

                  Akash Bhatt would you mind sharing your solution? or anybody else who understood how to combine "tabm, replace" with "tabulate" to then export the table in latex.

                  Thanks!
                  I am sorry I haven't been here for a while. I think the only difference in what I did was I used the unstack option with esttab. That should work

                  Comment

                  Working...
                  X