Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: loop thru unique values of a variable

From   Roger Newson <>
Subject   RE: st: loop thru unique values of a variable
Date   Tue, 10 Sep 2002 01:24:22 +0100

At 14:49 09/09/02 +0100, Nick Cox wrote:
I consider -vallist- (STB-60, updated on SSC) to be superseded
by -levels-
(SSC). Loosely speaking, -levels- does less, but it marks a retreat
to the main idea behind -vallist- and is designed to work more
and more smoothly with -foreach-. The difference may seem
small from a translation of Roger's example

levels D, local(values)
foreach d of local values {

but there are good reasons why this is slightly better style.
Except if D has non-integer values, in which case (as far as I can see) you have to use -vallist-.


Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605

Opinions expressed are those of the author, not the institution.

* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index