Statalist


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

st: putting value label categories into a matrix


From   "Milly Marston" <[email protected]>
To   <[email protected]>
Subject   st: putting value label categories into a matrix
Date   Mon, 10 Dec 2007 00:20:57 +0000

Hello 

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!

Thanks

Milly


*
*   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/



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