Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: export list to .txt or excel file


From   Phil Schumm <pschumm@uchicago.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: export list to .txt or excel file
Date   Mon, 2 Aug 2010 11:20:38 -0500

On Mon, Aug 2, 2010 at 10:19 AM, Hobst <tobias.friedli@access.uzh.ch> wrote:
I am working with the following code

levelsof Traded_Model, local(traded)
levelsof NewModel, local(new) local
onlytraded : list traded - new
local onlynew : list new - traded

now i would like to export the lists "onlytraded" and "onlynew" to use it in excel (so i need a .txt, .csv, .xls or whatever)..

Has somebody a suggestion how i could do that?


There are several possibilities here, depending upon exactly what you want. For a single list stored in the local macro onlytraded, you can use

    mata: mylist = invtokens(tokens(st_local("onlytraded")), char(10))
    mata: fh = fopen("foo.txt", "w")
    mata: fwrite(fh, mylist)
    mata: fclose(fh)

Not very efficient (i.e., you're tokenizing and then reassembling the list before writing it), but probably functional in most cases.


-- Phil

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index