[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Milly Marston" <Milly.Marston@lshtm.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: putting value label categories into a matrix |

Date |
Mon, 10 Dec 2007 13:53:24 +0000 |

Thanks Nick, Actually I am attempting strategy 1. I have a very large amount of data on different countries with similar data, but some with missing categories. If I can automate my tables in Stata first it saves time and also mistakes cutting and pasting. I am trying to produce a table in Stata that first has the variable categories (labelled) and then next to each category in columns various statistics I would like picked from different return codes. I will then use file write to export the final table. The reason I would like the matrix of data labels and values is so that for each variable I can identify how many categories there should be. Each country might have a missing category so if I wish them to line up at the end I want to make sure that where the category is missing I include a line blank with no statistics rather than having a shorter table that will not line up with others. Having the labels and their values in a matrix would make the identifying which label equates to which value easier than creating local macros from equal points from two different macro lists (labels and values). Conclusion, I think perhaps now's the time to delve into the world of Mata... Estout is a great friend of mine! It is very useful. Out of interest is there a reason why there isn't an option to put the actual data labels in the output (regression commands and estout) rather than the variable name with it's category number? ... perhaps that is for another thread Milly >>> "Nick Cox" <n.j.cox@durham.ac.uk> 10/12/2007 09:32 >>> You are in a bind here. If you want to put string values _into_ a matrix, you must use Mata, as Stata's matrices will not hold strings. You may use string values as labels for Stata matrices' rows and columns, but that's quite different. In any case, what you seem to want to do does not appear an especially good idea to me. You seem to be working backwards from the need to present tables, quite possibly in some other (unspecified) software. This is a very common desire among Stata users, but no one can agree on a single best solution. There are various routes that people prefer, depending partly on what other software they intend to use. Strategies include: 1. production of tables within Stata in a form more congenial than Stata's standard outputs. 2. production of results and/or tables by Stata as files readable by other programs, most commonly with a view to later use of one of various flavours of *TeX, or MS Word, or MS Excel. Popular solutions include -estout- (Ben Jann), -outreg2- (Roy Wada), -outreg- (John Gallup), -xml_tab- (Michael Lokshin, Zurab Sajaia), -parmest- etc. (Roger Newson). What I think you have in mind has more disadvantages and fewer advantages than any of these. A -findit- on the program names will indicate locations. If you come back to the list with specific questions, the various program authors usually reply very promptly. Nick n.j.cox@durham.ac.uk Milly Marston wrote I would like to get the value label categories of my variables into matrices so for a simple example For sex labelled 1=male and 2=female: 1 2 male female Where the first row is the values and the second the labels (or transposed) Is there anyway of doing this? Even extracting the value labels to be made into a list of strings in a macro would help. eg "male female" similar to what the extended macro functions do for variable label, or a return code in the label list command to capture the list in a matrix. I see that there is something in Mata using "st_vlmap" but unfortunately I am unfamiliar with Mata at the moment and have only been able to extract a scalar from the matrix to be used in Stata using "st_local" . Also with st_vlmap you seem to have to explicitly write down all the values labels you would like in the matrix whereas I would need it to be able to vary so I can put all my variables through the command without listing each number corresponding to the value label mata sexlabels=st_vlmap("sex", (1,2)) a=sexlabels[1,1] st_local(a) end display a Why am I doing this? - to save time so I can output my repeated results in a form as close to the tables I want for presentation as possible. I am not sure if I am missing something very simple, I appear to be going round and round in circles on this one, and if possible would like to avoid running with Mata before I can walk! * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: RE: RE: putting value label categories into a matrix***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: putting value label categories into a matrix***From:*"Milly Marston" <Milly.Marston@lshtm.ac.uk>

**st: RE: putting value label categories into a matrix***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: putting value label categories into a matrix** - Next by Date:
**st: Stata Users Meeting, London 8/9 September 2008** - Previous by thread:
**st: RE: putting value label categories into a matrix** - Next by thread:
**st: RE: RE: putting value label categories into a matrix** - Index(es):

© Copyright 1996–2022 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |