Statalist


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

Re: AW: st: AW: Displaying labeled values of variables


From   Miranda Kim <[email protected]>
To   [email protected]
Subject   Re: AW: st: AW: Displaying labeled values of variables
Date   Wed, 05 Aug 2009 09:14:03 +0100

Thanks a lot!


Martin Weiss wrote:
<>
Use - help extended_fcn-. I have never wanted to stash a var label into a
string variable, but if you insist on it, it is perfectly feasible:


*************
clear*
inp byte gender
0
1
0
0
1
1
1
0
1
0
end

la var gender "Subject's gender"

gen str30 labelvar=/* */ "`:var l gender '"

list, noobs

di in red "`:var l gender '"
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Miranda Kim
Gesendet: Mittwoch, 5. August 2009 10:01
An: [email protected]
Betreff: Re: st: AW: Displaying labeled values of variables

Thanks a lot for this! How could you do something similar with a variable label, for example:
lab var gender "Subject's gender"
How could I display "Subject's gender" using "disp"; and in addition, how could I define a new string variable that would hold that label?
Thanks for your help!

Martin Weiss wrote:
<>


*************
clear*
inp byte gender
0
1
0
0
1
1
1
0
1
0
end

la def gen 0 "female" 1 "male"
la val gender gen

di gender[7]

di "`:label (gender) `=gender[7]''"

forv i=1/10{
	di "`:label (gender) `=gender[`i']''"
}
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Miranda Kim
Gesendet: Dienstag, 4. August 2009 09:40
An: [email protected]
Betreff: st: Displaying labeled values of variables

A bit of a basic question...
say gender is a 0/1 (binary) variable with label sexlab where 0 = "Male" and 1 = "Female"
if I want to display this variable for observation i, I type:
di gender[i]
this will then display a 0 or 1
How could I change this to display it's 'labeled' value (i.e. "Male" or "Female") also, how can I define a new string variable that contains the 'labeled' values of gender?
Thanks a lot for your help.

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



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



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index