Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

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


From   Phil Schumm <[email protected]>
To   [email protected]
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 <[email protected]> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index