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: generate variable versus define scalar, with conditional statement

From   Nick Cox <>
Subject   Re: st: generate variable versus define scalar, with conditional statement
Date   Tue, 15 Jan 2013 13:59:09 +0000

See the review in excruciating detail in

@article \{dm0055,
	author = "Cox, N. J.",
	title = "Speaking Stata: Compared with ...",
	journal = "Stata Journal",
	publisher = "Stata Press",
	address = "College Station, TX",
	volume = "11",
	number = "2",
	year = "2011",
	pages = "305-314(10)",
	url = "";

Abstract.  Many problems in data management center on relating values
to values in other observations, either within a dataset as a whole or
within groups such as panels. This column reviews some basic Stata
techniques helpful for such tasks, including the use of subscripts,
summarize, by:, sum(), cond(), and egen. Several techniques exploit
the fact that logical expressions yield 1 when true and 0 when false.
Dividing by zero to yield missings is revealed as a surprisingly
valuable device.

On Tue, Jan 15, 2013 at 1:52 PM, annoporci <> wrote:
>> I doubt that you need to loop, but I am completely in the dark over
>> what it is that you want to do.
>> Nick
> I'm generating indices starting at different dates, so I want to use the
> value of the variable at some date of my choosing (not the first
> date in the dataset!) to generate an index starting at, say, the value 1,
> by dividing all observations by that value. Very simple. Probably one-line
> of code or less.
> ;-)
*   For searches and help try:

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