Announcement

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

  • dataset to table

    Hi, all. I have a dataset that contains results I would like to export directly to a table that matches the layout used for tables created with dtable. There is no additional analysis required for the data in this dataset -- I just want to take the rows and columns and put them in a nicely formatted table.

    For example, using the autos dataset, let's say I want to output a table containing the make, price and mpg for each observation.
    Make Price MPG
    AMC Concord 4099 22
    AMC Pacer 4799 17
    AMC Spirit 3799 22

    I've experimented with the following, which does not seem to reproduce the row structure of the data.

    Code:
    table make (price mpg ), statistic(firstnm price mpg ) nototals
    Let me know if anyone has a solution. Thanks!

  • #2
    Change price mpg to var.

    Code:
    . input str24 make price mpg
    
                             make      price        mpg
      1. "AMC Concord" 4099 22
      2. "AMC Pacer" 4799 17
      3. "AMC Spirit" 3799 22
      4. end
    
    . 
    . label var make "Make"
    
    . label var price "Price"
    
    . label var mpg "MPG"
    
    . 
    . table (make) (var), statistic(firstnm price mpg) nototals
    
    ----------------------------
                  |  Price   MPG
    --------------+-------------
    Make          |             
      AMC Concord |   4099    22
      AMC Pacer   |   4799    17
      AMC Spirit  |   3799    22
    ----------------------------

    Comment


    • #3
      Works like a charm. Thanks!

      Comment

      Working...
      X