Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: RE: numlabel gives syntax error on one specific dataset

From   Austin Nichols <>
Subject   Re: st: RE: numlabel gives syntax error on one specific dataset
Date   Wed, 23 Feb 2011 12:15:11 -0500

Is that -hexdump- output reporting on the contents of labels?  It is
easy to break -numlabel- with some odd characters in labels:

sysuse auto, clear
la def r 1 "poor" 2 "`=char(96)'fair" 3 "OK" 4 "good" 5 "superb"
la val rep78 r
ta rep78
numlabel, add force
ta rep78

But one can strip out all the weird characters from all the labels...

foreach var of var _all {
 loc la: val lab `var'
 if "`la'"!="" {
 qui levelsof `var', loc(ls)
 foreach l of loc ls {
loc v: label `la' `l'
loc g=subinstr("`v'",char(96),"",.)
forv h=123/255 {
 loc g=subinstr("`g'",char(`h'),"",.)
la def `la' `l' "`g'", modify

On Wed, Feb 23, 2011 at 10:03 AM, Nick Cox <> wrote:
> I said that Graham could send a copy to me. I confirm that I get his error message with his data. Looking at the labels there are some unprintable characters in his labels. So, I think he's right. It's a problem with his data.
> The error message, by the way, emanates from inside -matalabel-, but tracing it didn't seem the major part of valour.
> ASCII-fluent experts can perhaps ascertain [good word, isn't it] what may be alien from the results of -hexdump, tabulate-.
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index