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]
st: RE: RE: RE: RE: AW: AW: AW: AW: AW: Detach value label from string var
From
"Lachenbruch, Peter" <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: RE: RE: RE: AW: AW: AW: AW: AW: Detach value label from string var
Date
Wed, 7 Apr 2010 15:28:45 -0700
Was this a Titanic mistrake?
Tony
Peter A. Lachenbruch
Department of Public Health
Oregon State University
Corvallis, OR 97330
Phone: 541-737-3832
FAX: 541-737-4001
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Wednesday, April 07, 2010 9:58 AM
To: [email protected]
Subject: st: RE: RE: RE: AW: AW: AW: AW: AW: Detach value label from string var
I don't think they crossed; rather, the captain of my boat didn't see
yours in the fog.
Nick
[email protected]
Martin Weiss
Sure, I did give Nick credit in
http://www.stata.com/statalist/archive/2010-04/msg00333.html, our posts
must
have crossed - somewhere on the Atlantic.
Nick Cox
If this works, then with -findname- from SSC, the two calls to -ds-
could be
replaced by
findname, type(string) vall
after which `r(varlist)' can be invoked as here.
Martin Weiss
So here is a way to fake-define a -value label- for the string vars that
(seem to) have a -value label-. The example follows from the fake
dataset
created in my earlier conversation with Marc:
clear*
xmluse stata_out.xml
ds, has(type string)
ds `r(varlist)', has(vallabel)
foreach var of varlist `r(varlist)'{
cap la de `:value label `var'' 0 "test" 1 "test1"
di in r "Now at value label: `:val la `var'', RC is: " _rc
}
*************
The example shows the value of -ds- once again. We need to -capture- the
creation of the -label- since the same -label- may well be attached to
two
different variables, as is the case in my example. In the second line,
the
return code shows whether there was a problem or not.
Kaulisch, Marc
Martin,
I certainly can reproduce the behaviour with your example. So I get the
point that "string vars with embedded blanks" has nothing to do with the
value labels attached to string vars. But I get problems with empty
value
labels attached to string vars.
For example
. mlanguage add val, saving(val) // mlanguage is a user-written program
Produces an error because mylabel is not defined. Info: -labelbook, p-
does
not see a problem in this example.
It is possible to define mylabel
. la de mylabel 0 "test" 1 "test1"
Then: -mlanguage- works.
So a solution to my problem would be to define all value labels attached
to
a string var. Another solution would be to do not attach empty value
labels
to string vars in the first place (my favorite solution).
Or on Stata-side
- to improve the XML-Import that either such attachements to string vars
are
ignored or an error while importing is shown
- to allow the detachment of value labels from string vars
*
* 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/