Announcement

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

  • Combining several tables

    Dear Statlists,

    I am trying to combine several tables into one table.
    in the following code I create quantiles based on calmt for my variable score. For each quantile I want to create mean for all my variables. Since I create the table with "by quantile", I get 4 different tables. How can I combine these tables or is there any other way?

    Code:
    by calmt, sort: egen quantile = xtile (score), n(4)
    by quantile, sort: tabstat industry_adjusted_score volatility_per_isin variance_per_isin return_index gross_return , stat(mean)  columns (stat) save


    Moreover, how is it possible to create a new column in my table, where I subtract the first quantile from the fifth quantile and run a t-test over the results?

    I highly appreciate your help and thank you in advance.

  • #2
    Would anyone be so kind and help me out? I am really struggeling to solve this problem. Thank you.

    Comment


    • #3
      The second example in the help for tabstat has a single table showing means for several variables and groups of a further variable.

      The oldest advice is still the best. Read the documentation carefully! Try examples to see how they work.

      Code:
       . sysuse auto
      
          Show the mean (by default) of price, weight, mpg, and rep78
              . tabstat price weight mpg rep78
      
          Show the mean (by default) of price, weight, mpg, and rep78 by categories of foreign
              . tabstat price weight mpg rep78, by(foreign)
      Your second question is a request for a customised table. Programming it would take enormously longer than getting the results and editing a table in your favourite text processing environment. Stata does not promise that any arbitrary table can be produced in a few lines of code.

      Comment


      • #4
        Dear Nick,
        thank you for your advice. It really helped me out.
        One final question: I created the table as you mentioned
        Code:
        tabstat industry_adjusted_score volatility_per_isin variance_per_isin return_index gross_return, by (quantile) save

        Now I am trying to export the whole table to Excel with the following command:
        Code:
        matrix T3 = r(StatTotal)
        matrix X3 = T3'
        putexcel set "C:\Users\....xlsx"
        putexcel A1 = matrix(T3), names
        Apparently it shows me only one row called "mean", but not for each quantile and variable seperately. Do you know, how I can export the whole table and not only the row called "total".

        Thank you for your help.

        Comment


        • #5
          Check out tabstatmat (SSC) which may help first. Exporting tables to MS Excel is a popular topic except where I live, so I can't advise well.

          Comment


          • #6
            Thank you Nick for your help. I really appreciate it. Have a great time

            Comment

            Working...
            X