Announcement

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

  • Display full value label in results

    Hi all,

    Is there a way to stop Stata from truncating variable value labels in results tables (say in -proportion-) and widen the column for the variable value labels? For example, if in a dataset I want to see the proportion of observations by race, I get the following results table from -svy: proportion race, cformat(%9.2fc)-:

    Code:
    Survey: Proportion estimation
    
    Number of strata =       1        Number of obs   =     14,058
                                      Population size =  4,829,930
                                      Replications    =        178
                                      Design df       =        177
    
          _prop_4: sdracem = Asian/Pacific Island
          _prop_5: sdracem = Amer Ind/Alaska Natv
    
    --------------------------------------------------------------
                 |              Jackknife            Normal
                 | Proportion   Std. Err.     [95% Conf. Interval]
    -------------+------------------------------------------------
    sdracem      |
           White |       0.60       0.02          0.57        0.63
           Black |       0.15       0.01          0.13        0.17
        Hispanic |       0.18       0.01          0.15        0.21
         _prop_4 |       0.05       0.00          0.04        0.05
         _prop_5 |       0.02       0.01          0.00        0.03
           Other |       0.01       0.00          0.01        0.01
    --------------------------------------------------------------
    I can find options to change the format of the numeric results (as in the -cformat- option above), but not to change the width of the variable value labels column. I see the legend, and -nolegend- doesn't help here, either. I just want to see the full width of the variable value labels, even if they're quite wide.

    Barring the possibility of this, does anyone happen to know the number of characters allowed in a value label before truncation occurs?

    Thanks,
    Pete
    Last edited by Pete Ware; 13 Apr 2019, 23:27.

  • #2
    Short answer you won't like: The limit varies from command to command, depending on what else needs to be shown. If an option to tune the visible length isn't documented, the only way round is to write your own program.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Short answer you won't like: The limit varies from command to command, depending on what else needs to be shown. If an option to tune the visible length isn't documented, the only way round is to write your own program.
      Hi Nick,

      Thanks for the quick and yet, as you surmised, displeasing answer. I appreciate your willingness to share your expertise here!

      Comment


      • #4
        I have noticed the same issue with proportions but assumed it was some small bug. In the following example, my longest label is displayed perfectly and three shorter ones are not displayed:
        Code:
        . label list generation
        generation:
                   1 Pre-Silent
                   2 Silent
                   3 Boomers
                   4 Gen X
                   5 Millennials
                   6 Gen Z
        
        . proportion generation
        
        Proportion estimation             Number of obs   =     64,586
        
              _prop_1: generation = Pre-Silent
              _prop_4: generation = Gen X
              _prop_6: generation = Gen Z
        
        --------------------------------------------------------------
                     |                                   Logit
                     | Proportion   Std. Err.     [95% Conf. Interval]
        -------------+------------------------------------------------
        generation   |
             _prop_1 |   .1806583   .0015139      .1777101    .1836446
              Silent |   .2154337   .0016177      .2122799    .2186213
             Boomers |   .3698789   .0018996      .3661634    .3736099
             _prop_4 |   .1717245    .001484      .1688354    .1746527
         Millennials |   .0602762   .0009365      .0584666    .0621381
             _prop_6 |   .0020283    .000177      .0017093    .0024067
        --------------------------------------------------------------

        Comment


        • #5
          The length of the label isn't the key here in #4. Rather, it's value labels that could not be legal Stata names that are being substituted by nonce names. So Pre-Silent contains a hyphen and the other labels not shown contain spaces. But I agree that your output is not what a user wants or expects to see.

          (Whether it is a case of length biting in #1 I can't check without making up a data example.)

          Comment


          • #6
            Sure enough, Nick, you were correct. Since value labels are strings I never suspected that they could not display a space or a dash in some circumstances. Here is an example without these characters:

            Code:
            #d ;
            label define gentest 1 "PreSilent"
                                 2 "Silent"
                                 3 "Boomers"
                                 4 "GenX"
                                 5 "Millennials"
                                 6 "GenZ";
            #d cr
            label values generation gentest
            
            proportion generation
            Which produces:

            Code:
            . proportion generation
            
            Proportion estimation             Number of obs   =     64,586
            
            --------------------------------------------------------------
                         |                                   Logit
                         | Proportion   Std. Err.     [95% Conf. Interval]
            -------------+------------------------------------------------
            generation   |
               PreSilent |   .1806583   .0015139      .1777101    .1836446
                  Silent |   .2154337   .0016177      .2122799    .2186213
                 Boomers |   .3698789   .0018996      .3661634    .3736099
                    GenX |   .1717245    .001484      .1688354    .1746527
             Millennials |   .0602762   .0009365      .0584666    .0621381
                    GenZ |   .0020283    .000177      .0017093    .0024067
            --------------------------------------------------------------
            Underscores are displayed correctly.

            Best,
            Alan

            Comment


            • #7
              Nick,
              Your reply 10 years ago was that there is no preprogrammed way to stop truncating value labels in results windows (at least for tabulate). Is that still true? Has someone posted a program to do this?
              Thanks,
              Arnold Levinson

              Comment


              • #8
                The -tabulate- command still works exactly as it did before. However, if you are using version 17 or later, the -table- command lists value labels in full. At least I now it has never truncated any of mine--there may be a limit to the length it will allow, but I have yet to encounter it. Do read -help table- before trying to use it if you don't already know how.

                Comment


                • #9
                  At one level, this is all too simple. A value label can be up to 32 characters long. Whether there is enough space in some output to show such labels in their entirety and whether a command supports that total flexibility vary from command to command, and it's likely that some people will call that inconsistency. The crux is identifying which commands don't support that flexibility -- without obvious reason.

                  My own experience and focus are probably in a corner of user space. I often and strongly want informative text labels on graphs in a way that complements rather than confuses those graphs themselves, but that means text, such as value labels, usually being quite short. I rarely want highly complicated tables with very long text strings.

                  Comment


                  • #10
                    Thanks, Clyde and Nick. It's the tabulate command I'm using right now. I certainly think Stata is inconsistent - it's far and away my preferred analytic software. But the --svy: tab-- command shows only eight characters, although the results window has plenty of room. I then have to follow with a --tab-- command to get the labels. No biggie, just a minor inconvenience I was hoping someone might have programmed away. Thanks again.

                    . svy, subpop(northelig if lgbtp2==1): tab whatuse year, col
                    (running tabulate on estimation sample)

                    Number of strata = 32 Number of obs = 28,290
                    Number of PSUs = 28,060 Population size = 12,499,511
                    Subpop. no. obs = 1,401
                    Subpop. size = 824,547.36
                    Design df = 28,028

                    --------------------------------------
                    | Year
                    whatuse | 2015 2018 2022 Total
                    ----------+---------------------------
                    none | .3241 .4928 .4437 .4478
                    only smo | .0649 .0705 .0476 .0577
                    only vap | .016 .0474 .0495 .045
                    only use | .2795 .2141 .2598 .2457
                    smoke & | .0178 .0186 .0154 .0168
                    vape tob | .0503 .0448 .0796 .0639
                    smoke to | .1591 .0714 .0685 .0797
                    all thre | .0883 .0404 .0357 .0433
                    |
                    Total | 1 1 1 1
                    --------------------------------------

                    . tab whatuse

                    whatuse | Freq. Percent Cum.
                    -----------------------+-----------------------------------
                    none | 24,291 73.92 73.92
                    only smoke cigs | 1,996 6.07 79.99
                    only vape tobacco | 476 1.45 81.44
                    only use MJ | 3,963 12.06 93.50
                    smoke & vape tobacco | 288 0.88 94.38
                    vape tobacco & use MJ | 423 1.29 95.67
                    smoke tobacco & use MJ | 1,109 3.37 99.04
                    all three | 315 0.96 100.00
                    -----------------------+-----------------------------------
                    Total | 32,861 100.00


                    Comment


                    • #11
                      So, I think you have a feature request there.

                      Comment


                      • #12
                        Sorry, I meant to say "Stata is NOT inconsistent".

                        Comment


                        • #13
                          Thanks, Nick.

                          Comment


                          • #14
                            How does one submit a feature request?

                            Comment


                            • #15
                              Post it on the Wishlist for Stata 19 thread, which is a "sticky" topic near the top of the General Forum page.

                              Comment

                              Working...
                              X