Thanks to Kit Baum, a new package -labgen- is now downloadable from SSC.
-labgen- requires Stata 8.
It contains two commands, to generate or replace variables with
definitions copied to variable labels. There is more after my signature.
Nick
[email protected]
-labgen- generates a new variable using -generate-, except that the
definition of the variable, i.e. whatever follows the equals sign,
including any -if- or -in- qualifiers specified, becomes the variable
label.
-labreplace- replaces an existing variable using -replace-, except that
the definition of the variable, i.e. whatever follows the equals sign,
including any -if- or -in-qualifiers specified, becomes the variable
label.
Thus
labgen logy = ln(y)
creates a new variable -logy- with variable label "ln(y)". Similarly
labreplace logy = ln(y) if foo > 2
replaces variable -lny- with a new variable label "ln(y) if foo > 2".
A first version of -labgen- was posted by Paul Lin, then working for
what is now StataCorp, to Statalist on 16 July 1996. I posted a revision
on 18 July 1996. At this distance I cannot trace what the difference
was.
Alan H. Feiveson drew my attention to -labgen- once more in Statalist
postings on 25 September 2008 and persuaded me publicly to resuscitate
it. He deserves much of any credit and a small fraction of any blame
that you may deem deserved for its re-publication.
-labgen- as published on SSC is rewritten and -labreplace- is new as of
13 October 2008.
The help carries more details as usual.
For other commands in similar spirit, search -genl- and see Weesie
(1997), or search -defv- and see Gleason (1997, 1999). If I have
overlooked yet others, please let me know.
Gleason, J.R. 1997. Defining variables and recording their definitions.
Stata Technical Bulletin 40: 9-10. (STB Reprints 7: 48-49)
http://www.stata.com/products/stb/journals/stb40.pdf
Gleason, J.R. 1999. Update to defv. Stata Technical Bulletin 51: 2.
(STB Reprints 9: 14-15)
http://www.stata.com/products/stb/journals/stb51.pdf
Weesie, J. 1997. Automatic recording of definitions. Stata Technical
Bulletin 35: 6-7. (STB Reprints 6: 18-20)
http://www.stata.com/products/stb/journals/stb35.pdf
*
* 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/