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]

Re: st: RE: RE: FW: Possible to generate a variable and specifying the label?

From   Nick Cox <>
Subject   Re: st: RE: RE: FW: Possible to generate a variable and specifying the label?
Date   Tue, 29 Nov 2011 07:53:42 +0000

I am still a bit fuzzy on exactly what is sought here. But J.J. could
write a program that took on its command line all the instructions
needed, and for all I know one exists somewhere. If so, why is it not
better known? My guess is that you end up typing the same stuff any
way and so there is no real gain in packing it into one long command
rather than two or three shorter ones.


On Tue, Nov 29, 2011 at 7:38 AM, J. J. Wen

> Thank you for your response. Too bad that it is not possible to do that "on
> line", however thank you for the insights!

Jesper Lindhardsen

> I think that would require you to define the label beforehand, which may or
> may not be feasible. So in essence you only "get rid" of on line, that is,
> the -label values- statement (at least in 11.2 ....)
> clear all
> set obs 10
> label define Lab 0 "Zero"
> g var:Lab=0

J. J. Wen

> I am fairly new at Stata 12, so the question I ask might be a bit simple and
> uninteresting for advanced users. I've already tried to look for a solution,
> however I couldn't find any. The problem is as follows: I would like to
> generate a variable including specifying the label name (i.e. I would like
> to generate variable X and at the same time specifying the label name
> instead of specifying it afterwards). Now I've looked at the following:
> and came to the conclusion that generate
> [type] newvar[:lblname] =exp [if] [in] is the command I was looking for.
> I
> tried the following:
> gen NewVar:testlblName = X
> (note: where NewVar is the name of the new variable and testlblName is the
> label name I wanted to give NewVar; please bear with me that this is useless
> command, only used for experimenting with Stata 12 as NewVar would be the
> same as the list of points in X.)
> Could someone give an example of how to correct do this? Or point my
> mistake? I am almost certain that this is possible, however I can't seem to
> get it work.
*   For searches and help try:

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