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" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Getting at value labels
Date   Sun, 15 Feb 2004 17:07:19 -0000

Roger Harbord
 
> I wrote the short ado-file below a while back, prompted by a 
> colleague's 
> request for help in overlaying twoway plots for several 
> groups on the same 
> axes and using the value labels in the legend.   It seems 
> from this thread 
> that other people have encountered the same issues.

Should be useful for many. Note that it will fail if -over()- 
names a string variable. 

> (In case anyone wonders, i avoided using -separate- in the code below 
> because of difficulties ensuring the variables it creates are 
> temporary.)

tempname temp 
separate myvar, by(whatever) gen(`temp') 
local sepvars "`r(varlist)'" 

works in practice in Stata 8, at least. Whether that's a back door 
which StataCorp will lock in future versions I can't say. 

This exploits two (apparent) facts. 

1. Even in Stata 8, temporary names are no longer than 
8 characters. So a statement somewhere in the 
documentation that you cannot add suffixes 
to temporary names is no longer correct. 

2. Conversely, when a program ends all variables
whose names begin with __ (underscore underscore) 
are -drop-ped. 

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

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index