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

Re: st: from variable to macro


From   Roger Newson <[email protected]>
To   [email protected]
Subject   Re: st: from variable to macro
Date   Mon, 18 Nov 2002 13:05:16 +0000

At 12:36 17/11/02 -0800, Shige Song wrote:
Dear All,

I'd like to know how to generate a macro out of a numerical variable. For example, I have a variable A that includes 200 values, I want to generate a macro X that contains all the values that variable A has so that I can do something like:

foreach x of local X {

qreg ... , q(x)

}
You should probably use Nick Cox's -vallist- command (type -ssc describe vallist- to find out more). Your program might be as follows:

vallist A
local vals "`r(list)'"
foreach X of numlist `vals' {
qreg ... , q(x)
}

I hope this helps.

Roger


--
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
Email: [email protected]

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

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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