Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: RE: RE: RE: AW: AW: AW: AW: AW: Detach value label from string var


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: RE: AW: AW: AW: AW: AW: Detach value label from string var
Date   Wed, 7 Apr 2010 17:58:26 +0100

I don't think they crossed; rather, the captain of my boat didn't see
yours in the fog. 

Nick 
n.j.cox@durham.ac.uk 

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index