Announcement

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

  • Tabstat & Long Variable Names

    Hi there,

    I'm using tabstat to summarize a number of variables. They have long variable names (about 20 characters, sometimes more) and they are quite similar. Tabstat truncates them. Is there any way to expand the column with the variable name so I can see the entire name?

    Example below:
    sysuse auto, clear
    rename foreign foreigncartype1renamed
    generate foreigncartype2renamed = foreigncartype1renamed
    tabstat foreigncartype1renamed foreigncartype2renamed, col(statistics)

    Using this example, I know I can differentiate between the two variables since I can see the portion of the variable name that's different (1 and 2 in the table), but in other cases, this isn't the case.

    Thank you in advance for any assistance you can offer.

    Best,
    Erika

  • #2
    I don't think you can get names this long completely printed out in the stub of a -tabstat- table. But if you add the -varwidth(16)- option to your command, you will get variable names that are abbreviated in the middle by eliding "cartype" and replacing that with a "~". The resulting table is a little better (but not much):

    Code:
     .  tabstat foreigncartype1renamed foreigncartype2renamed, col(statistics) varwidth(16)
              variable |      mean
    -----------------+----------
    foreign~1renamed |  .2972973
    foreign~2renamed |  .2972973
    ----------------------------
    The obvious extension of this would be to specify a number greater than 16 in the -varwidth()- option, but 16 is the maximum -tabstat- will accept.

    The -table- command offers more formatting flexibility, though you might have to go through some data management contortions to get the data layout you are looking for here.
    Last edited by Clyde Schechter; 26 Nov 2014, 13:05.

    Comment


    • #3
      I suggest that you in general avoid (too) long variable names and that you rename your variable names to shorter, handier, yet still informative names; a number of commands abbreviate long variable names to something that can be difficult to read.

      Comment


      • #4
        Thank you for this information and these suggestions. I did a bit more digging, and it looks like the user-written fsum is able to accommodate longer variable names, which is a nice workaround.

        Best,
        Erika

        Comment

        Working...
        X