Announcement

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

  • Table statistic() problem

    Hi all. For some reason, the table function does not work as intended. This is just an example, but as in the tutorial, I want to get a table of means for v1 and v2 across the levels of a1, so I use:

    Code:
    table a1, statistic(mean v1 v2)
    However, I always get an error:

    Code:
    option statistic() not allowed
    I have tested this function with sample datasets, but it never works for some reason. Could anybody help?

  • #2
    Have you reviewed the output of help table? Nothing I see there suggests a statistic() option, and Stata confirmed that conclusion with its error message.

    On some invented data, the following seems to have accomplished what you are seeking.
    Code:
    . table a1, contents(mean v1 mean v2)
    
    ----------------------------------
           a1 |   mean(v1)    mean(v2)
    ----------+-----------------------
            1 |   .0374306    1.061475
            2 |  -.0891936    1.233092
            3 |   .2968465    1.009843
    ----------------------------------

    Comment


    • #3
      the following certainly works using the auto.dta:
      Code:
      table foreign, stat(mean gear mpg)
      so I think there is something you are not telling us; it is always easier to respond helpfully if a -dataex- data example is provided (please see the FAQ)

      Comment


      • #4
        Rich's success leads me to remember that I wrote post #2 using Stata 16.1. A check of the current (thus, version 17) online documentation at

        https://www.stata.com/manuals/rtableintro.pdf

        suggests that table has seen some significant improvements in Stata 17.

        Perhaps post #1 was created with an older version of Stata?

        Comment


        • #5
          In fact, in version 17, unless you apply version control, the old syntax shown in #2 is no longer accepted:
          Code:
          . sysuse auto, clear
          (1978 automobile data)
          
          . table foreign, stat(mean gear mean mpg)
          variable mean not found
          (error in option statistic())
          r(111);
          I suspect William Lisowski is right that O.P. tried using the version 17 syntax in an older version of Stata.

          I'm somewhat surprised that Stata didn't choose a different name for the new command considering how radically it has been revised. Then again, the name -table- is hard to beat, and I recall that when they introduced their current system of graphics back in version, was it 7?, also a very radical change, they didn't change the name of the command either.

          The functionality of the new -table- command is quite good, although it takes a bit of time to learn it. I'm really just beginning to get a grasp on it now, but with stumbling around on its syntax, I'm still finding it a real time-saver compared to hacking my own code to produce similar results.

          Comment


          • #6
            Clyde Schechter

            I'm somewhat surprised that Stata didn't choose a different name for the new command considering how radically it has been revised. Then again, the name -table- is hard to beat, and I recall that when they introduced their current system of graphics back in version, was it 7?, also a very radical change, they didn't change the name of the command either.
            Given that tabulate is taken, tab is the allowed and customary abbreviation, and less predictable names like tabdisp and tabstat are also already taken I imagine that the developers went back and forth on this a bit and decided that being able to use the old table syntax under version control solves most problems quickly.

            StataCorp take a long view and consider that old users are willing and smart enough to adapt with the occasional stumble or two. 18 years after the new graphics in Stata 8, there is just very occasional confusion between old and new that is easily resolved.

            Comment

            Working...
            X