Announcement

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

  • To export results of tabout command to a excel file

    Hello everyone
    I have a problem should ask everyone


    In dofile:

    use ask3, clear
    gen sl1 = 1 if c2b_1==1 //tu nguyen
    gen sl2 = 1 if c2b_2==1 //tu chu
    gen sl3 = 1 if c2b_3==1 //von gop
    gen sl4 = 1 if c2b_4==1 //sudung
    gen sl5 = 1 if c2b_5==1 //tiencong

    tabout bomay chuyen loaihinh sxkd htxmoi tyle lienket ///
    sl using tabout2.xls, ///
    c(N sl1 N sl2 N sl3 N sl4 N sl5) ///
    f(0c) ///
    layout(row) ptotal(single) ///
    sum replace


    tabout bomay chuyen loaihinh sxkd htxmoi tyle lienket ///
    sl using tabout3.xls, ///
    c(N sl1 N sl2 N sl3 N sl4 N sl5) ///
    f(0c) ///
    layout(row) ptotal(single) ///
    sum replace



    I want to add tabout3 to a sheet in tabout2
    (maybe name is sheet3)

    How can i do everyone?


    (I'm using version 13 stata)

    Thank in advance everyone!


    http://www.mediafire.com/download/66...wz2hv/ask3.dta

  • #2
    huhong asked me about this but I am afraid I have no idea. I thought I would bump it just in case all the people who are experts on this are back from their richly deserved vacations now. ;-)
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      Thank in advance Sir Richard Williams!

      Comment


      • #4
        As far as I know there's no way to accomplish this with tabout (a user written program by Ian Watson available from IDEAS).

        Tabout does not write files in an excel format. You've given your file an .xls extension but it's still just a text file with tab separated values.

        If you want something that writes excel files directly you should look at the putexcel command, which does let you specify the worksheet you write to.

        Comment


        • #5
          I would recommend esttab (wrapper for estout for this task). These programs are on SSC: ssc install estout to get them both. (And in the estout help file there is a clickable link through to the extensive documentation on RePEC, where examples for you are in the Advanced section.http://repec.org/bocode/e/estout/adv...ml#advanced905 )
          My suggested strategy is to create the matrix of results that you require: call it "e". Then you can write lines like
          Code:
          esttab matrix(e) using filename.rtf, replace  // "e" is the matrix name
          And there are options for choosing the number of decimal places reported. RTF format files are directly readable by MS Word and various other software including OpenOffice. Alternatively use an "xlx" file extension rather than "rtf" to save to Excel
          Last edited by Stephen Jenkins; 04 Oct 2014, 04:09.

          Comment


          • #6
            Thanks Stephen!
            I'm studying your command,
            If it is ok, I will tell you

            Comment


            • #7
              Dear Stephen Jenkins
              I tried to do follow your suggest, but, maybe my knowledge can't complete.

              Please to download my file (ask3.dta)
              http://www.mediafire.com/download/66...wz2hv/ask3.dta
              and see my dofile

              and guide me to add tabout3.xls to tabout2.xls (by name sheet3) (The sheet3 is a sheet in file tabout2.xls)

              many thanks Stephen Jenkins

              Comment


              • #8
                Sorry, but I am not going to download a file from an external website (it could be anything); nor do I want to want to look in detail at the code you posted in your first message (because it is not easily legible). And you don't say with any specificity what the problem is now.
                There is a general problem with your request too: you are pushing all the onus for a response onto me, and apparently making little effort yourself! Put yourself in the position of a Forum reader -- why should someone want to respond to you in such a situation? You should be helping us to help you. Please read the Forum FAQ in this connection. Note well the points about how to post good questions; and the recommendations about posting selections of your data set (and file types) and posting code, including the requests to show us exactly what you typed and exactly what Stata gave back, and to use CODE delimiters when doing so.

                Comment


                • #9
                  Stephen is entirely right here and giving very good advice.

                  Typically people will answer questions they find interesting on which they have something to say, which can be said in a few minutes, but Statalist is not a way to get other people to do all your coding for you.

                  Comment


                  • #10
                    Both Stephen and Nick have given good advice about posting code.

                    I am at this point going to reiterate my original answer: look at the built-in Stata command putexcel.

                    All of the user-written commands I know of for exporting these kinds of tables write file formats that are readable by Excel but are not native excel formats. So if you use esttab or tabout you will be able to open each of the files you produce in excel but they'll be separate files. Someone can correct me if I'm wrong here but I do not believe there is any way to use esttab to write multiple different worksheets to a single excel file.

                    Your goal is to end up with a single excel file with multiple worksheets. You can do this one of two ways.
                    1. You can write multiple files and open each of them and then manually combine them into a single file. For this strategy you could use esttab or tabout.
                    2. You can use putexcel (possibly combined with export excel, depending on the exact task at hand) to write the multiple worksheets directly to a single excel file.

                    If you have a small number of worksheets or if this is a task that you will be doing infrequently it may be easiest to go with what you already know and combine the resulting files yourself.
                    If you're creating a file with a large number of worksheets or if this is a task you will be doing regularly, learning how to use putexcel (and possibly export excel) to get the file you want without having to combine files may be worth it.

                    Comment


                    • #11
                      Dear Sarah Edgington,

                      Many thanks for your reply,

                      I ensure to can export tabout by excel format file. I did, it is ok, no problem

                      I'm always must to create many table for my job (hundred excel file), I don't like it.
                      I want to export this excel files into a single excel file.

                      I sent email to Ian Watson, but i received no answer.

                      I understand your guide, but my knowledge can't do it.
                      So, can you write dofile to do it from my dofile?

                      Many thanks Sarah Edgington

                      Comment


                      • #12
                        Dear Stephen Jenkins, Nick Cox

                        You don't understand what i said

                        I want to ensure that you can do it success for my file

                        Your guide only to stop at suggest. Can you ensure you can success with my file?

                        I tried to do follow your guide, but it isn't success
                        (It's mean: I don't want you do any thing for me)

                        Are you clear?

                        Thank you

                        Comment


                        • #13
                          Dear all,

                          I have a answer from Ian Watson (ago 15 minutes)

                          "Hello. There is no way to add Excel sheets together, but you can make multiple tables which will all go into the one sheet. Just use the append option."

                          I post on this forum for who care this problem

                          Many thanks all!

                          Comment


                          • #14
                            Dear Sarah Edgington

                            This is command that Ian Watson edited for me:

                            tabout bomay chuyen loaihinh sxkd htxmoi tyle lienket ///
                            sl using tabout2.xls, ///
                            c(N sl1 N sl2 N sl3 N sl4 N sl5) ///
                            f(0c) ///
                            layout(row) ptotal(single) ///
                            sum replace

                            tabout bomay chuyen loaihinh sxkd htxmoi tyle lienket ///
                            sl using tabout2.xls, ///
                            c(N sl1 N sl2 N sl3 N sl4 N sl5) ///
                            f(0c) ///
                            layout(row) ptotal(single) ///
                            sum append

                            Note that you keep the same filename, tabout2.xls, and when you open this in Excel, you will see both tables on the same sheet.


                            Many thanks you!

                            Comment


                            • #15
                              Hoang:
                              before adressing sentences like
                              You don't understand what i said
                              to two authoritative contributors of this Forum, I would check if my query was clear enough for others on the list to reply. Thanks.

                              Kind regards,
                              Carlo
                              Kind regards,
                              Carlo
                              (Stata 19.0)

                              Comment

                              Working...
                              X