Announcement

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

  • Exporting multiple descriptive tables in excel format using the command foreach

    Hi all,

    I have a large longitudinal dataset and I created already all the tables I need using the command foreach. The syntax I used is this one: (I only put a few of the variables as an example)

    foreach x in ///
    A001_ A002_ A003_ G040_ G041_ G043_ G051_ {
    table country,c(m `x'1 m `x'2 m `x'3 m `x'4) format(%5.2f) missing
    }


    In which the statistics I indicated are the different waves of the dataset. In this way I would have the tables with the percentage of the variables I want for every country and for every year.

    My problem is now to export all these tables in an excel format, since now I only have them saved in a log file. Would you know how to do it?
    Last edited by Gianluca Reolon; 15 Mar 2022, 08:38.

  • #2
    You can use asdocx (which is available for $9.99) for this task. Here is an example:
    Code:
    sysuse nlsw88
    asdocx table industry married, save(table.xlsx)
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	28.7 KB
ID:	1654613


    All you have to do is to add asdocx to the beginning of the Stata code and use xlsx extension with the file name. asdocx has dozens of other useful features for creating customized tables, see details here https://fintechprofessor.com/asdocx/
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Look at -putexcel- Stata command which can be used to export varieties of Stata outputs in Excel. To do that type -help putexcel-. Stata blog also has a demonstration series on this which you can look at (See for Part-2 of the series here ).

      Also please see the FAQ section and familiarize yourself with how to post a question here in the forum. Specially how to provide data examples using -dataex- and use of code delimiters to provide Stata codes and outputs.
      Last edited by Roman Mostazir; 16 Mar 2022, 09:11.
      Roman

      Comment

      Working...
      X