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]

Re: st: using information from value label to generate new variables


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: using information from value label to generate new variables
Date   Fri, 8 Jun 2012 11:39:15 +0200

Nick is, of course, right. There are still limits in what can be
stored in r(), but these are the limits of macros in Stata, and it is
unlikely to hit them here. Stata's limits are documented in -help
limits-. As a side issue on strings, let me tell you that at the
German Stata Users Group meeting there was a question about the 244
character limits in strings. Bill Gould answered that question very
quickly, annoncing that "We'll fix that.".

As -labellist- is part of the -labutil2- package (SSC) , Evelyn may
use -labcpy- to get rid of the 5-diget regional codes in value labels.
Typing

labcpy location location2 (10000/99999 = .) ,val(a1-a9)

will create <location2> as a new value label with all 5-diget regional
code labels removed. The label will be attached to variables <a1-a9>.

Best
Daniel
-- 
Daniel Klein, the author of -labellist- (SSC), may want to comment,
but he did exactly the right thing in defining -labellist-'s saved
results.

Evelyn's problem arise from using an equals sign in

quietly: labellist locations
local loc_levels= r(locations_values)

Evelyn should have gone

quietly: labellist locations
local loc_levels `r(locations_values)'

The equals sign evaluates the expression to its right, and that
truncates it. Here copying alone is sufficient. For more on this
biting beast, see

SJ-8-4  pr0045  . . . . . . . . Stata tip 70: Beware the evaluating equal sign
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q4/08   SJ 8(4):586--587                                 (no commands)
        tip explaining the pitfall of losing content in a macro
        because of limits on the length of string expressions

Nick
n.j.cox@durham.ac.uk
*
*   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