Announcement

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

  • Variable Labels Appear in List?

    I apologize if this is too simple a question, but I want the colum headers of my list to be the labels of the variables as follows:

    Code:
    label var ldlvl "Liberal Democracy Level"
    label var fhlvl "Freedom House Level"
    label var plvl "Polity Level"
    label var twnkill "GTD Total"
    label var twnfatal "RDWTI"
    label var twntranskill "GTD Transntl"
    label var twndead "ITERATE"
    
    forvalues i=0/8 {
    list country_name ldlvl twnkill twnfatal twntranskill twndead if ldlvl==`i'
    }
    I looked through the help file and couldn't find an option that would do this for me-- does anyone know whether such an option exists or whether there exists an acceptable substitute command that amounts to the same thing? My end goal is to export this to a word or excel document, and since i will repeat this many times, it would save me a lot of energy if there was a simple way to do it.

    thanks in advance,

    Julian

  • #2
    I don't know of any way to get -list- to do this. But if what you really want is to export to Excel with the variable labels as headers look at the -firstrow(varlabels)- option of the -export excel- command. There is nothing directly analogous to this for Word documents, but copy/paste between Excel and Word works very well in most situations.

    Comment


    • #3
      thanks clyde, that works much more smoothly.

      best,

      julian

      Comment


      • #4
        I agree with Clyde. For those interested in the original question, my guess is that there is no option to do this is that it is because almost always there is insufficient room to make it practical. But it is programmable.

        Code:
        sysuse auto, clear 
        
        foreach v of var * { 
            char `v'[varname] `"`: var label `v''"' 
        }
        
        l make price mpg, subvarname abbrev(20) 
        
             +--------------------------------------------+
             | Make and Model       Price   Mileage (mpg) |
             |--------------------------------------------|
          1. | AMC Concord          4,099              22 |
          2. | AMC Pacer            4,749              17 |
          3. | AMC Spirit           3,799              22 |
          4. | Buick Century        4,816              20 |
          5. | Buick Electra        7,827              15 |
             |--------------------------------------------|
          6. | Buick LeSabre        5,788              18 |
          7. | Buick Opel           4,453              26 |
          8. | Buick Regal          5,189              20 |
          9. | Buick Riviera       10,372              16 |
         10. | Buick Skylark        4,082              19 |
             |--------------------------------------------|
         11. | Cad. Deville        11,385              14 |
         12. | Cad. Eldorado       14,500              14 |
         13. | Cad. Seville        15,906              21 |
         14. | Chev. Chevette       3,299              29 |
         15. | Chev. Impala         5,705              16 |
             |--------------------------------------------|
         16. | Chev. Malibu         4,504              22 |
         17. | Chev. Monte Carlo    5,104              22 |
         18. | Chev. Monza          3,667              24 |
         19. | Chev. Nova           3,955              19 |
         20. | Dodge Colt           3,984              30 |
             |--------------------------------------------|
         21. | Dodge Diplomat       4,010              18 |
         22. | Dodge Magnum         5,886              16 |
         23. | Dodge St. Regis      6,342              17 |
         24. | Ford Fiesta          4,389              28 |
         25. | Ford Mustang         4,187              21 |
             |--------------------------------------------|
         26. | Linc. Continental   11,497              12 |
         27. | Linc. Mark V        13,594              12 |
         28. | Linc. Versailles    13,466              14 |
         29. | Merc. Bobcat         3,829              22 |
         30. | Merc. Cougar         5,379              14 |
             |--------------------------------------------|
         31. | Merc. Marquis        6,165              15 |
         32. | Merc. Monarch        4,516              18 |
         33. | Merc. XR-7           6,303              14 |
         34. | Merc. Zephyr         3,291              20 |
         35. | Olds 98              8,814              21 |
             |--------------------------------------------|
         36. | Olds Cutl Supr       5,172              19 |
         37. | Olds Cutlass         4,733              19 |
         38. | Olds Delta 88        4,890              18 |
         39. | Olds Omega           4,181              19 |
         40. | Olds Starfire        4,195              24 |
             |--------------------------------------------|
         41. | Olds Toronado       10,371              16 |
         42. | Plym. Arrow          4,647              28 |
         43. | Plym. Champ          4,425              34 |
         44. | Plym. Horizon        4,482              25 |
         45. | Plym. Sapporo        6,486              26 |
             |--------------------------------------------|
         46. | Plym. Volare         4,060              18 |
         47. | Pont. Catalina       5,798              18 |
         48. | Pont. Firebird       4,934              18 |
         49. | Pont. Grand Prix     5,222              19 |
         50. | Pont. Le Mans        4,723              19 |
             |--------------------------------------------|
         51. | Pont. Phoenix        4,424              19 |
         52. | Pont. Sunbird        4,172              24 |
         53. | Audi 5000            9,690              17 |
         54. | Audi Fox             6,295              23 |
         55. | BMW 320i             9,735              25 |
             |--------------------------------------------|
         56. | Datsun 200           6,229              23 |
         57. | Datsun 210           4,589              35 |
         58. | Datsun 510           5,079              24 |
         59. | Datsun 810           8,129              21 |
         60. | Fiat Strada          4,296              21 |
             |--------------------------------------------|
         61. | Honda Accord         5,799              25 |
         62. | Honda Civic          4,499              28 |
         63. | Mazda GLC            3,995              30 |
         64. | Peugeot 604         12,990              14 |
         65. | Renault Le Car       3,895              26 |
             |--------------------------------------------|
         66. | Subaru               3,798              35 |
         67. | Toyota Celica        5,899              18 |
         68. | Toyota Corolla       3,748              31 |
         69. | Toyota Corona        5,719              18 |
         70. | VW Dasher            7,140              23 |
             |--------------------------------------------|
         71. | VW Diesel            5,397              41 |
         72. | VW Rabbit            4,697              25 |
         73. | VW Scirocco          6,850              25 |
         74. | Volvo 260           11,995              17 |
             +--------------------------------------------+
        list is often underestimated as a tabulation command. I often let list be the workhorse for results output in programs. The ability to set a characteristic to be informative header is a particularly useful detail.

        Comment

        Working...
        X