Announcement

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

  • Exporting multiple list results to same Excel file

    Hello,

    I'm trying to write a do file that will automate data quality checks, and as part of that I'd like it to generate a "report" in Excel that will list all the issues I've identified.

    I know how to use outsheet to generate a file that lists one column, say all the individuals (pid) who are missing a certain variable, say ecc1:

    outsheet pid using filename if mi(ecc1) [, options]

    Is there a way to:
    a) Do this for multiple lists in the same file?
    b) Add column headings to each in order to distinguish them?


    I've looked all over the forum and can't find any info on this, so I'm wondering if it's even possible.Thanks so much Statalist!

    -Reese

  • #2
    Are you using an old version of Stata? Currently, -outsheet- has been superseded by -export delimited-, though the former still works. Moreover, if you are looking to put your results into Excel, why go through a text file intermediate? Why not use -export excel- directly. Basically, write your Stata code to create a data set that contains whatever information you need to put into Excel. Then -export excel- will get you there (and it does have an option for column headings). See -help export excel-.

    Comment


    • #3
      Thanks a lot for the reply, Clyde. I should have included in my OP that I'm using Version 14. Your suggestion is really helpful. Export excel seems perfect for my purpose to combine multiple lists in the same excel file (i.e. cell() and sheetmodify options).

      However, it seems like the only column heading option is to use either variable names or labels. Considering each column in my final dataset will comprise pid's, I would like some way to generate "custom" column headings. Do you think my best option is to change the variable name to my "custom" name, export, reload the dataset without saving, and repeat?

      Thanks,
      Reese

      Comment


      • #4
        Do you think my best option is to change the variable name to my "custom" name, export, reload the dataset without saving, and repeat?
        That would be one approach. An alternative which might be simpler is to change the variable label to your custom name, and export using the variable labels as the column headers. I'm not sure it makes much difference which way you do it.

        Comment


        • #5
          I agree, labels would be better I think. Thanks so much for your help!

          Comment

          Working...
          X