Announcement

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

  • Data editor: How to adjust column width?

    Hi everybody,

    I wasn't able to find a solution. I want to be able to properly read the value labels, but the column width is too small.

    Thanks!
    Jan

  • #2
    Despite the fact that your data has value labels, the width of the column is apparently controlled by the numeric format assigned to the variable. If you change the format before opening the browser, the width of the column will be adjusted. Here's an example of creating, rather than solving, the problem you've experienced.

    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . browse make foreign in 1/5
    Click image for larger version

Name:	8g.png
Views:	1
Size:	48.1 KB
ID:	1393601

    Code:
    . format foreign %4.0g
    
    . browse make foreign in 1/5
    Click image for larger version

Name:	4g.png
Views:	1
Size:	46.2 KB
ID:	1393602

    Comment


    • #3
      Thank you so much William!

      That was exactly what I was looking for!

      Comment


      • #4
        Thank you so much William, that helped me too.

        Comment


        • #5
          Thank you William!

          Comment


          • #6
            The previously mentioned format option is a good one. Another option is to set the column width characteristic. I like this option because the implementation is the same for both string and numeric variables. For example,

            Code:
            sysuse sandstone, clear
            
            char depth[_de_col_width_] 8
            char type[_de_col_width_] 16

            Comment


            • #7
              I really like the solution using the width characteristics. Here is a simple program that I have started to add to all my do files to quickly resize all columns and browse more easily. Hope somebody else will find it useful.

              Code:
              capture program drop resizeCol
              program define resizeCol
                  quietly: ds
                  local vars `r(varlist)'
                  foreach v of local vars {
                      char `v'[_de_col_width_] 12
                  }
              end

              Comment


              • #8
                Originally posted by Tyson Van Alfen View Post
                The previously mentioned format option is a good one. Another option is to set the column width characteristic. I like this option because the implementation is the same for both string and numeric variables. For example,

                Code:
                sysuse sandstone, clear
                
                char depth[_de_col_width_] 8
                char type[_de_col_width_] 16
                Where did you find the '_de_col_width_' charname to use here?

                Comment


                • #9
                  Originally posted by James Everson View Post

                  Where did you find the '_de_col_width_' charname to use here?
                  https://www.stata.com/manuals/u12.pd...haracteristics. Note: more info linked at the end of the section.

                  Comment


                  • #10
                    Originally posted by Rune Schmidt Qvist View Post

                    https://www.stata.com/manuals/u12.pd...haracteristics. Note: more info linked at the end of the section.
                    Thank you!

                    Comment


                    • #11
                      Originally posted by Paul Obermann View Post
                      I really like the solution using the width characteristics. Here is a simple program that I have started to add to all my do files to quickly resize all columns and browse more easily. Hope somebody else will find it useful.

                      Code:
                      capture program drop resizeCol
                      program define resizeCol
                      quietly: ds
                      local vars `r(varlist)'
                      foreach v of local vars {
                      char `v'[_de_col_width_] 12
                      }
                      end
                      Wow... been looking for this answer for a long time... thanks!!

                      Comment


                      • #12
                        You can resize variable columns directly in the Data Editor by selecting 1 or more columns using the variable-column headers, then resizing any of those selected columns by dragging the resize divider between the columns. The new sizes will be recorded as characteristic of the resized variables as previously indicated by others. Any modified characteristics will be saved with the dataset.

                        To resize a single column, no selection is required.

                        Click image for larger version

Name:	Screenshot 2023-07-12 190108-2.png
Views:	1
Size:	109.0 KB
ID:	1720274

                        Comment


                        • #13
                          .

                          Comment

                          Working...
                          X