Announcement

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

  • Tabulate values into 4 quarters in a page

    Hi All,

    I have a dataset that I want to show the prices before and after a certain date in two separate sections of a tabulate output. My dataset (please see a snippet below) has products in "prod," prices "rel_px," dates "td_combined_date," and country "country." Ideally, I would like a table in a word document which has UK on one side and Ireland on the other divided into top and bottom by pre-tax (prior to mar2016) and post tax (after mar2016). Does anyone know how to create these 4 quadrants all within one table aside from manually copying and pasting the values myself? I would like the table to include the mean and std dev for rel_px and number of observations for each good. If this cannot easily be coded into STATA directly, I can instead copy and paste it into a word doc and try to modify some of the outputs myself. I was hoping to use some function of outreg2 because it fits with the visual appearance of my regression outputs, but I would be happy if anyone has any solution other than that as well. Thank you all so much!




    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str21 prod float(rel_px td_combined_date) str7 country
    "Allitems"      .997 19724 "Ireland"
    "Allitems"   .988024 19724 "UK"     
    "Allitems"     1.002 19755 "Ireland"
    "Allitems"   .993014 19755 "UK"     
    "Allitems"     1.009 19783 "Ireland"
    "Allitems"    .99501 19783 "UK"     
    "Allitems"      1.01 19814 "Ireland"
    "Allitems"   .999002 19814 "UK"     
    "Allitems"     1.009 19844 "Ireland"
    "Allitems"   .998004 19844 "UK"     
    "Allitems"     1.011 19875 "Ireland"
    "Allitems"         1 19875 "UK"     
    "Allitems"     1.009 19905 "Ireland"
    "Allitems"   .997006 19905 "UK"     
    "Allitems"     1.011 19936 "Ireland"
    "Allitems"         1 19936 "UK"     
    "Allitems"     1.008 19967 "Ireland"
    "Allitems"  1.000998 19967 "UK"     
    "Allitems"     1.006 19997 "Ireland"
    "Allitems"  1.001996 19997 "UK"     
    "Allitems"     1.003 20028 "Ireland"
    "Allitems"   .999002 20028 "UK"     
    "Allitems"      .999 20058 "Ireland"
    "Allitems"   .999002 20058 "UK"     
    "Allitems"      .991 20089 "Ireland"
    "Allitems"   .991018 20089 "UK"     
    "Allitems"      .997 20120 "Ireland"
    "Allitems"   .993014 20120 "UK"     
    "Allitems"     1.003 20148 "Ireland"
    "Allitems"    .99501 20148 "UK"     
    "Allitems"     1.003 20179 "Ireland"
    "Allitems"   .997006 20179 "UK"     
    "Allitems"     1.007 20209 "Ireland"
    "Allitems"   .999002 20209 "UK"     
    "Allitems"     1.009 20240 "Ireland"
    "Allitems"         1 20240 "UK"     
    "Allitems"     1.007 20270 "Ireland"
    "Allitems"   .998004 20270 "UK"     
    "Allitems"     1.011 20301 "Ireland"
    "Allitems"  1.000998 20301 "UK"     
    "Allitems"     1.006 20332 "Ireland"
    "Allitems"         1 20332 "UK"     
    "Allitems"     1.004 20362 "Ireland"
    "Allitems"  1.000998 20362 "UK"     
    "Allitems"     1.001 20393 "Ireland"
    "Allitems"  1.000998 20393 "UK"     
    "Allitems"         1 20423 "Ireland"
    "Allitems"  1.000998 20423 "UK"     
    "Allitems"      .992 20454 "Ireland"
    "Allitems"   .993014 20454 "UK"     
    "Allitems"      .996 20485 "Ireland"
    "Allitems"   .996008 20485 "UK"     
    "Allitems"         1 20514 "Ireland"
    "Allitems"         1 20514 "UK"     
    "Allitems"     1.002 20545 "Ireland"
    "Allitems"         1 20545 "UK"     
    "Allitems"     1.007 20575 "Ireland"
    "Allitems"  1.001996 20575 "UK"     
    "Allitems"     1.014 20606 "Ireland"
    "Allitems" 1.0039921 20606 "UK"     
    "Allitems"     1.012 20636 "Ireland"
    "Allitems" 1.0039921 20636 "UK"     
    "Allitems"      1.01 20667 "Ireland"
    "Allitems"  1.006986 20667 "UK"     
    "Allitems"     1.006 20698 "Ireland"
    "Allitems" 1.0089821 20698 "UK"     
    "Allitems"     1.001 20728 "Ireland"
    "Allitems" 1.0099801 20728 "UK"     
    "Allitems"         1 20759 "Ireland"
    "Allitems" 1.0119761 20759 "UK"     
    "Allitems"         1 20789 "Ireland"
    "Allitems" 1.0169661 20789 "UK"     
    "Allitems"      .995 20820 "Ireland"
    "Allitems" 1.0119761 20820 "UK"     
    "Allitems"     1.001 20851 "Ireland"
    "Allitems" 1.0189621 20851 "UK"     
    "Allitems"     1.007 20879 "Ireland"
    "Allitems" 1.0229541 20879 "UK"     
    "Allitems"     1.011 20910 "Ireland"
    "Allitems" 1.0269462 20910 "UK"     
    "Allitems"     1.009 20940 "Ireland"
    "Allitems" 1.0309381 20940 "UK"     
    "Allitems"      1.01 20971 "Ireland"
    "Allitems" 1.0309381 20971 "UK"     
    "Allitems"      1.01 21001 "Ireland"
    "Allitems" 1.0299401 21001 "UK"     
    "Allitems"     1.014 21032 "Ireland"
    "Allitems" 1.0359281 21032 "UK"     
    "Allitems"     1.008 21063 "Ireland"
    "Allitems" 1.0389222 21063 "UK"     
    "Allitems"     1.007 21093 "Ireland"
    "Allitems" 1.0399202 21093 "UK"     
    "Allitems"     1.005 21124 "Ireland"
    "Allitems" 1.0439122 21124 "UK"     
    "Allitems"     1.004 21154 "Ireland"
    "Allitems" 1.0469062 21154 "UK"     
    "Allitems"      .997 21185 "Ireland"
    "Allitems" 1.0419163 21185 "UK"     
    "Allitems"     1.006 21216 "Ireland"
    "Allitems" 1.0469062 21216 "UK"     
    end
    format %d td_combined_date

  • #2
    This can be done using a custom template in asdocx https://fintechprofessor.com/asdocx/
    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


    • #3
      Thank you--do you (or anyone else) possibly have suggestions for how to even properly code this output? After thinking about it, the only result I've thought of (which would be unnecessarily time consuming) is

      Code:
      tabstat rel_px if prod=="Allitems" & country=="Ireland", stat(mean sd max min)
      I would then have to write this code for each product within the "prod" variable and also for all of the "UK" observations, totaling to upwards of 100 individual lines. Even if it were not outputted in a well-formatted way, do you know how to create one of the four boxes? To clarify, one of the boxes would be:
      • For all products underneath "prod" variable (which includes more than just "Allitems")
      • If td_combined_date >=%td(mar2016)
      • If country==Ireland
      If I could create that output (including mean, sd, max, and min for each of the products under "prod") then I would simply make the three other tables for when the date was for a different time, and the country was the UK. Please let me know if you have any suggestions for the best tabulate command, or if tabulate is not the best approach to use. Thank you!

      Best,
      Jim

      Comment

      Working...
      X