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

st: Re: Extended macro problem


From   Roger Newson <[email protected]>
To   [email protected]
Subject   st: Re: Extended macro problem
Date   Tue, 01 Jun 2004 10:00:59 +0100

At 00:17 01/06/04 -0700, Kaleb wrote (in reply to Fred):
Fred,

You're going to groan yourself when you see the error. Everything's fine, but you're assuming the name of the label values is the same name as the categorical variable. In the case of sex, it works out, but edcat's label is edcode2 and what the code basically does is:

local edcatlab0 : label edcat 0

when what you really want is:

local edcatlab0 : label edcode2 0

Just add a line that grabs the correct label value name before this and you should be good.

Kaleb...
Or Fred could have written the malfunctioning line as

local `catvar'lab`num': label (`catvar') `num'

(note the parentheses), which refers to the label of the variable stored in the macro -catvar-. See -[P] macro- for details.

Or, alternatively, Fred might like to use the -factext- package, downloadable from my website. (A fully up to date version should be on SSC as soon as Kit gets back to Boston.) The -factext- package inputs the -label- variable in a -parmby- output and re-creates the categorical factors, sometimes with help from the -descsave- package, which is also on SSC. The categorical factors can then be used in plots and tables.

I hope this helps.

Best wishes

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]
Website: http://www.kcl-phs.org.uk/rogernewson

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