Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Getting at value labels


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Getting at value labels
Date   Fri, 13 Feb 2004 14:12:58 -0000

Correct about the missing quotes and other 
careless slips. Thanks for the polish. 

To put this in context, the results of 

. separate mpg, by(foreign) shortlabel

              storage  display     value
variable name   type   format      label      variable label
------------------------------------------------------------------------
-------
mpg0            byte   %8.0g                  foreign == Domestic
mpg1            byte   %8.0g                  foreign == Foreign

are too long-winded for my graphical tastes. 

For a graph, I'd personally want to zap further "foreign == " 
and the corresponding lines should be more like. 

local eq = index(`"`label'"', "=") 
local label = substr(`"`label'"',`eq'+3,.)  

That's what more or less -labnoeq- does, any way. 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of 
> Arnold Kester
> Sent: 13 February 2004 13:59
> To: [email protected]
> Subject: Re: st: RE: Getting at value labels
> 
> 
> Two missing quotes and a missing part in the label string, imho.
> 
> Nick Cox wrote:
> > I would do this. I assume value labels attached
> > to -marEduc-. 
> > 
> > separate aRate, by(marEduc) shortlabel 
> > local aRatevars "`r(varlist)'" 
> > twoway connected `aRatevars' year 
> > 
> > Sometimes even the -shortlabel- is too long. 
> > (There should be an option -veryshortlabel-
> > to go beyond the -shortlabel- I suggested 
> > a while back.)  
> > 
> > ssc inst labutil 
> > labnoeq `aRatevars' 
> > 
> > will cut them down further. The first principles
> > way to do that is something like 
> > 
> > foreach v of local aRatevars { 
> > 	local label : variable label `v' 
> 
> Here a ' missing:
> 
> > 	local eq = index(`"`label'"', "=") - 1
> 
> and here a ' and the second part of the string
> 
> > 	local label = 
> substr(`"`label'"',1,`eq')+substr(`"`label'"',`eq'+4,.)  
> > 	label var `v' `"`label'"' 
> > } 
> >  
> I'd been looking for this for some time, so I tried it right 
> away. Thanks.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index