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, statalist.org is already up and running.


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

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


From   "Kaulisch, Marc" <kaulisch@forschungsinfo.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: RE: RE: AW: AW: AW: AW: AW: AW: AW: AW: Detach value label from string var
Date   Thu, 8 Apr 2010 09:06:26 +0200

Of course, this is only a preliminary solution until we get a better
XML-export from our survey. Changing the xml-import file manually would
be too time-consuming (more than 50 string vars).

The purpose was to prepare our dataset for the usage of -mlanguage- (see
Wessie 2005 http://stata-journal.com/article.html?article=dm0013).

To document the solutions found:
***
* Detach empty value labels from numeric vars
codebook, p
label values `r(labelnotfound)' . 

* Delete duplicate value labels
labeldup, select 

* Unify value labels to prefix l
* solution proposed by Martin Weiss in
http://stata.com/statalist/archive/2010-04/msg00252.html
label dir

foreach val in `r(names)' {
	cap assert substr("`val'",1,1) ~= "l"
	if !_rc labelrename `val' `="l"+"`val'"'
}

* Define value labels attached to string vars (attached by xml-import)
* solution proposed by Martin Weiss in
http://stata.com/statalist/archive/2010-04/msg00333.html
findname, type(string) vall

foreach var of varlist `r(varlist)' {
cap la de `:value label `var'' 0 "t"
di in r"Now at value label: `:val la `var'', RC is: " _rc
}

* Create new language, saving do-file for translation
mlanguage add val, saving(val) 
***

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