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 on April 23, and its replacement, 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" <>
To   <>
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. 


Martin Weiss

Sure, I did give Nick credit in, our posts
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
created in my earlier conversation with Marc:

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
different variables, as is the case in my example. In the second line,
return code shows whether there was a problem or not.

Kaulisch, Marc


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
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-
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
a string var. Another solution would be to do not attach empty value
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
ignored or an error while importing is shown
- to allow the detachment of value labels from string vars

*   For searches and help try:

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