Announcement

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

  • ds - how to display fullnames

    Dear Statalisters -

    I have a large dataset and am looking to list out the names of all my string variables. I have found the command ds which has provided the ability to limit the output of the variables to string: ds, has(type string)

    Unfortunately we have some longer variable names in the dataset which means that a number of them are summarized using the ~ mid variable name. For example:
    cf_antibio~r
    qol_entere~y
    qol_startt~e

    I'd like to have the full variable name output here instead, yet the fullnames option (used within d procedure) doesn't work in this command.

    Does anyone have suggestions for outputting the names of all string variables from a dataset as full names?

    Thanks in advance for your advice.

    Best,
    Alison

  • #2
    There is no guarantee that option that exist for one command also exist for another (why would it?) If you want to know what options are available after ds you just type help ds. There you see that one of the options is varwidth(#). The helpfile describes it as: "display width for variable names; default is varwidth(12)". So by default the variables names truncated to 12 characters, but you can change that with the varwidth() option.

    Another way to get at this is use the fact that Stata commands often leave information behind in memory. You can see what is left behind by typing return list (or ereturn list after an estimation command like regress). ds leaves behind the list of variable names in r(varlist), so you can use that:

    Code:
    . clear
    
    . input some_really_long_name
    
         some_re~e
      1. 1
      2. end
    
    .
    . ds, varwidth(22)
    some_really_long_name
    
    .
    . ds
    some_reall~e
    
    . di r(varlist)
    some_really_long_name
    Last edited by Maarten Buis; 17 May 2023, 01:43.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thank you so much, Maarten. I appreciate your calling attention to this alternative way to obtain the output that I was after despite the option not being included within the procedure.

      Comment

      Working...
      X