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]

st: RE: RE: Read variable labels

From   "Liao, Junlin" <>
To   "" <>
Subject   st: RE: RE: Read variable labels
Date   Mon, 21 Feb 2011 20:35:30 +0000


This is very helpful. Thanks very much.


-----Original Message-----
From: [] On Behalf Of Nick Cox
Sent: Monday, February 21, 2011 1:54 PM
To: ''
Subject: st: RE: Read variable labels

In addition, it may be worth knowing about -label language-.

Also, if the long labels were ever thought good, you might want them again in the future, so various ways of backing up might be considered.


Nick Cox

Suppose you want to replace "University" by "U" in a bunch of variable labels.

foreach v of var * {
        local label : var label `v'
        local label : subinstr local label "University" "U", all
        label var `v' `"`label'"'

The key stuff here is documented at help -extended_fcn-. As Maarten was remarking only the other day, it's sometimes easier to remember to go to the help for -macro- and then jump.

-varm- is good for doing this for a few labels.

Liao, Junlin

Does anyone know how to read out variable labels? For example, I have a group of variables with long labels. I want to programmatically shorten the labels by replacing keywords. How do I get the variable labels in functions?

*   For searches and help try:

Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.

*   For searches and help try:

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