tabulate has the Option matcell() to save the output table in a file. Unfortunately the limits are 1200 rows and 80 columns, but i have much more columns. Is there a possibility to do something similar as matcell with the table function?
Thanks for your advice. 
<> The matcell() option does not save to a file, but a matrix: *********** sysuse auto, clear tab rep78, matcell(h) mat l h *********** table has a replace option that gives you access to almost unlimited space to save the result. Combine it with preserve/restore: *********** sysuse auto, clear table rep78, contents(freq) replace l *********** HTH Martin Original Message From: [hidden email] [mailto:[hidden email]] On Behalf Of Hobst Sent: Montag, 12. Juli 2010 23:41 To: [hidden email] Subject: st: Equivalent to matcell in table tabulate has the Option matcell() to save the output table in a file. Unfortunately the limits are 1200 rows and 80 columns, but i have much more columns. Is there a possibility to do something similar as matcell with the table function? Thanks for your advice.  View this message in context: http://statalist.1588530.n2.nabble.com/Equivalenttomatcellintabletp5285 038p5285038.html Sent from the Statalist mailing list archive at Nabble.com. * * 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/ * * 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/ 
I see, thank you. But how can i access the created table with for example xml_tab? My goal is to save the crated matrix (which is about 700x700) to a .txt or .xml file, so i can use it in Excel later..
Thank you very much for your help. I reallly appreciate it.
On 13.07.2010, at 00:04, Martin Weiss5 [via Statalist] wrote:

 On 13.07.2010, at 00:04, Martin Weiss wrote:
> > table has a replace option that gives you access > > to almost unlimited space to save the result. Combine > > it with preserve/restore:  On Wed, 14/7/10, Hobst wrote: > how can i access the created table with for example > xml_tab? My goal is to save the crated matrix (which > is about 700x700) to a .txt or .xml file, so i can > use it in Excel later.. table with the replace option stores your results in the current Stata data set, so you can just use outfile to export that as a txt file. Now the real question is what do you want to use Excel for: this is almost certainly a mistake, if only because that will prevent you from getting reproducable results. Hope this helps, Maarten  Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl  * * 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/ 
I already have a excel file with all the Solver stuff set up to do some optimization on a log likelihood function derived from the matrix. I would like to do it in Stata, but i am just do not have the skills to programm it in stata, this is why i use excel for the optimization.
If i use the outfile i get a .txt with some tousend rows and 3 colums. But what i want is to have the matrix (as displayed for table , i.e 700 rows and 700 colums). how can i do that? On 14.07.2010, at 12:52, Maarten buis wrote: >  On 13.07.2010, at 00:04, Martin Weiss wrote: >>> table has a replace option that gives you access >>> to almost unlimited space to save the result. Combine >>> it with preserve/restore: > >  On Wed, 14/7/10, Hobst wrote: >> how can i access the created table with for example >> xml_tab? My goal is to save the crated matrix (which >> is about 700x700) to a .txt or .xml file, so i can >> use it in Excel later.. > > table with the replace option stores your results in > the current Stata data set, so you can just use outfile > to export that as a txt file. Now the real question is > what do you want to use Excel for: this is almost > certainly a mistake, if only because that will prevent > you from getting reproducable results. > > Hope this helps, > Maarten > >  > Maarten L. Buis > Institut fuer Soziologie > Universitaet Tuebingen > Wilhelmstrasse 36 > 72074 Tuebingen > Germany > > http://www.maartenbuis.nl >  > > > > > * > * 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/ * * 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/ 
 On Wed, 14/7/10, Tobias Friedli wrote:
> I already have a excel file with all > the Solver stuff set up to do some optimization on a log > likelihood function derived from the matrix. I would like to > do it in Stata, but i am just do not have the skills > to programm it in stata, this is why i use excel for the > optimization. That worries me. Regardless of its strenghts and weaknesses, Excel just is not made to do this kind of stuff. You really really really want to use purpose written software, like Stata, to this kind of maximization of the likelihood, it is just too easy to get it wrong. If you want to implement your model in Stata (and I repeat, I strongly recommend that you do), than you will want to have this book on your desk: http://www.stata.com/bookstore/mle.html In addition, if you can wait a while, during the next Italian Stata Users' meeting there will be a course on programming in Stata: <http://www.stata.com/meeting/italy10/> > If i use the outfile i get a .txt with some tousend > rows and 3 colums. But what i want is to have the matrix (as > displayed for table , i.e 700 rows and 700 colums). how > can i do that? You will need to use reshape to get your data in the right format. Hope this helps, Maarten  Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl  * * 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/ 
i totally agree with you! And i have the mentioned book right in front of me :).. But as this calculations are for my bachelor thesis my time frame is very limited, i have never worked with Stata before, and i just dont have the time to learn all this (it is not even the core topic of my thesis...). i tried to, but till now i was not able to implement it, and at the University of Zürich i don't have anybody to help me with it. The excel calculations are definitely not best way but for me at my level of Skills, the only way possible... But anyways thank you for your advice, i will maybe attend the course in Italy, so i have more skills for future reasearch projects. To all of you Statalists, i really appreciate all your work to help people with Stata Problems, even with noob questions like the questions i always ask... Whitout you guys i would definitely be lost...
i will try the reshape and report back. Thanks On 14.07.2010, at 13:27, Maarten buis wrote: >  On Wed, 14/7/10, Tobias Friedli wrote: >> I already have a excel file with all >> the Solver stuff set up to do some optimization on a log >> likelihood function derived from the matrix. I would like to >> do it in Stata, but i am just do not have the skills >> to programm it in stata, this is why i use excel for the >> optimization. > > That worries me. Regardless of its strenghts and weaknesses, > Excel just is not made to do this kind of stuff. You really > really really want to use purpose written software, like Stata, > to this kind of maximization of the likelihood, it is just > too easy to get it wrong. > > If you want to implement your model in Stata (and I repeat, > I strongly recommend that you do), than you will want to > have this book on your desk: > http://www.stata.com/bookstore/mle.html > > In addition, if you can wait a while, during the next Italian > Stata Users' meeting there will be a course on programming > in Stata: <http://www.stata.com/meeting/italy10/> > >> If i use the outfile i get a .txt with some tousend >> rows and 3 colums. But what i want is to have the matrix (as >> displayed for table , i.e 700 rows and 700 colums). how >> can i do that? > > You will need to use reshape to get your data in the right > format. > > Hope this helps, > Maarten > >  > Maarten L. Buis > Institut fuer Soziologie > Universitaet Tuebingen > Wilhelmstrasse 36 > 72074 Tuebingen > Germany > > http://www.maartenbuis.nl >  > > > > > * > * 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/ * * 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/ 
In reply to this post by Maarten buis
This is what i have:
NewModel Traded_Model table1 Expedition 2.3CL 1 Montero_Sport 2.3CL 1 200SX 200SX 1 4Runner 200SX 1 626 200SX 2 Accord 200SX 2 Alero 200SX 1 .... ... ... where "table1" are the frequencies This is what i want: 2.3 CL 200SX ..... Expedition 1 1 Mondeo Sport 1 200SX 0 1 ...... I tried the following: reshape wide table1, i(Traded_Model) j(NewModel) string Then i get the error message Table12.3CL invalid name. Any suggestions where i am wrong? On 14.07.2010, at 13:27, Maarten buis wrote: >  On Wed, 14/7/10, Tobias Friedli wrote: >> I already have a excel file with all >> the Solver stuff set up to do some optimization on a log >> likelihood function derived from the matrix. I would like to >> do it in Stata, but i am just do not have the skills >> to programm it in stata, this is why i use excel for the >> optimization. > > That worries me. Regardless of its strenghts and weaknesses, > Excel just is not made to do this kind of stuff. You really > really really want to use purpose written software, like Stata, > to this kind of maximization of the likelihood, it is just > too easy to get it wrong. > > If you want to implement your model in Stata (and I repeat, > I strongly recommend that you do), than you will want to > have this book on your desk: > http://www.stata.com/bookstore/mle.html > > In addition, if you can wait a while, during the next Italian > Stata Users' meeting there will be a course on programming > in Stata: <http://www.stata.com/meeting/italy10/> > >> If i use the outfile i get a .txt with some tousend >> rows and 3 colums. But what i want is to have the matrix (as >> displayed for table , i.e 700 rows and 700 colums). how >> can i do that? > > You will need to use reshape to get your data in the right > format. > > Hope this helps, > Maarten > >  > Maarten L. Buis > Institut fuer Soziologie > Universitaet Tuebingen > Wilhelmstrasse 36 > 72074 Tuebingen > Germany > > http://www.maartenbuis.nl >  > > > > > * > * 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/ * * 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/ 
Sorry for DoublePost, the formatting wasn't right, i hope it is better now:
This is how i have the data now: ... ... ... And this is how i would like to have it: i tried it with the following code: reshape wide table1, i(Traded_Model) j(NewModel) string i got the error messsage: table12.3CL invalid name Does anybody see what i am doing wrong? Thank you 
In reply to this post by Hobst
<>
> > I tried the following: > reshape wide table1, i(Traded_Model) j(NewModel) string > Then i get the error message Table12.3CL invalid name. Any suggestions where i am wrong? > You can't have a variable name with a period "." in it. See "help varname". You can subinstr() the period. The data transformation you request in your posting below doesn't match your next posting with the .png images. In the post below you've got indicators of the traded_models (1/0) after the reshape, but in the png files you've got some kind of count (?) of the traded_models after the reshape. Here's a guess at what you might be looking for. If not, please provide a more clear example/explanation. ****************! //this first section creates the fake dataset you provided: **run this in a new dofile editor window** clear inp str15(newmodel traded_model) table1 "expedition" "2.3CL" 1 "montero_sport" "2.3CL" 1 "200SX" "200SX" 1 "4Runner" "200SX" 1 "626" "200SX" 2 "accord" "200SX" 2 "alero" "200SX" 1 "expedition" "200SX" 1 "expedition" "200SX" 1 end //this cleans up the newmodel and traded_model vars: replace newmodel = subinstr(newmodel, "_", " ", .) replace newmodel = proper(newmodel) replace traded_model = subinstr(traded_model, ".", "_", .) //next, you need some identifiers to reshape with: **see help reshape g id = _n bys traded_: g modelid_ = _n //reshape: reshape wide modelid_, i(id) j(traded_) string order newmodel drop id //change to 1's and 0's: recode modelid_* (.=0) (1/max = 1) /* This next section assumes that you want to get this data to one record per newmodel, and in doing so, that you want some kind of: (1) indicator that the traded_model was traded for the newmodel, or (2) count of the number of traded_models traded for each new model */ ds modelid_* foreach v in `r(varlist)' { **count of traded_models by newmodel** bys newmodel: egen `v'_count = total(`v') ** indicate if each traded_model = 1** bys newmodel: egen `v'_m = max(`v') replace `v' = `v'_m if `v' < `v'_m drop `v'_m } duplicates drop newmodel, force li, noobs clean ****************! ~ Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University [hidden email] Office: +979.845.6754 On Jul 14, 2010, at 7:00 AM, Tobias Friedli wrote: > This is what i have: > > NewModel Traded_Model table1 > Expedition 2.3CL 1 > Montero_Sport 2.3CL 1 > 200SX 200SX 1 > 4Runner 200SX 1 > 626 200SX 2 > Accord 200SX 2 > Alero 200SX 1 > .... ... ... > > where "table1" are the frequencies > > This is what i want: > > 2.3 CL 200SX ..... > > Expedition 1 1 > Mondeo Sport 1 > 200SX 0 1 > > ...... > > I tried the following: > > reshape wide table1, i(Traded_Model) j(NewModel) string > > Then i get the error message Table12.3CL invalid name. Any suggestions where i am wrong? > > > > > On 14.07.2010, at 13:27, Maarten buis wrote: > >>  On Wed, 14/7/10, Tobias Friedli wrote: >>> I already have a excel file with all >>> the Solver stuff set up to do some optimization on a log >>> likelihood function derived from the matrix. I would like to >>> do it in Stata, but i am just do not have the skills >>> to programm it in stata, this is why i use excel for the >>> optimization. >> >> That worries me. Regardless of its strenghts and weaknesses, >> Excel just is not made to do this kind of stuff. You really >> really really want to use purpose written software, like Stata, >> to this kind of maximization of the likelihood, it is just >> too easy to get it wrong. >> >> If you want to implement your model in Stata (and I repeat, >> I strongly recommend that you do), than you will want to >> have this book on your desk: >> http://www.stata.com/bookstore/mle.html >> >> In addition, if you can wait a while, during the next Italian >> Stata Users' meeting there will be a course on programming >> in Stata: <http://www.stata.com/meeting/italy10/> >> >>> If i use the outfile i get a .txt with some tousend >>> rows and 3 colums. But what i want is to have the matrix (as >>> displayed for table , i.e 700 rows and 700 colums). how >>> can i do that? >> >> You will need to use reshape to get your data in the right >> format. >> >> Hope this helps, >> Maarten >> >>  >> Maarten L. Buis >> Institut fuer Soziologie >> Universitaet Tuebingen >> Wilhelmstrasse 36 >> 72074 Tuebingen >> Germany >> >> http://www.maartenbuis.nl >>  >> >> * * 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/ 
Thanky you. i did it! But somehow different
I cleanes up the Variables and then just reshape wide table1, i(Traded_Model) j(NewModel) string and it almost worked. I had to rename all the Models that begin with an number , for example 200SX by n2000SX. I did that manually Model by Model... Is there an easier way how to do that? (identify all the Traded_Model and NewModel that start with a number and put a "n" in front of it) I need a more automated approach, because i need to do steps i did today for 45 other Datasets, which do not necessarily contain the same model names... After that it worked fin :)... Thank you so much all your help 
<>
2 ideas: ***************! clear inp str10 model "sx200" "nx200" "302a" "1111" end **1. add m_ to all strings in a var** g model2 = "m_" + model **or** **2. just the strings that start with a number** clonevar model3 = model forval n = 0/9 { g pos`n' = strpos(model3, "`n'") replace model3 = "m_" + model3 if pos`n'==1 drop pos`n' } li ***************! Also, you might consider appending or joining the 45 datasets together first and then making modifications. ~ Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University [hidden email] Office: +979.845.6754 On Jul 14, 2010, at 12:40 PM, Hobst wrote: > Thanky you. i did it! But somehow different > > I cleanes up the Variables and then just > > reshape wide table1, i(Traded_Model) j(NewModel) string > > and it almost worked. > > I had to rename all the Models that begin with an number , for example 200SX > by n2000SX. > I did that manually Model by Model... Is there an easier way how to do that? > (identify all the Traded_Model and NewModel that start with a number and put > a "n" in front of it) I need a more automated approach, because i need to do > steps i did today for 45 other Datasets, which do not necessarily contain > the same model names... > > After that it worked fin :)... Thank you so much all your help > > > >  > View this message in context: http://statalist.1588530.n2.nabble.com/Equivalenttomatcellintabletp5285038p5293896.html > Sent from the Statalist mailing list archive at Nabble.com. > * > * 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/ * * 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/ 
Powered by Nabble  Edit this page 