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

st: RE: RE: from string to nummeric

From   Roger Newson <>
Subject   st: RE: RE: from string to nummeric
Date   Wed, 31 Mar 2004 12:40:42 +0100

At 12:15 31/03/04 +0100, Nick Cox wrote (in reply to Daniel Mueller's reply to

In addition, a fairly strung-out discussion is given
in "On numbers and strings" Stata Journal 2(3):314--329
(2002). That needs updating on the detail that -tostring-
is now part of official Stata.

The main story there is to think of methods as coming
in pairs:

-encode- and -decode- for strings vs numeric variables
with value labels;

-tostring- and -destring- for when the present variable
type is essentially a mistake (perhaps yours, perhaps

-real()- and -string()- as the brute force conversion
Another pair is -sencode- and -sdecode-, which are "super" versions of -encode- and -decode-, respectively. Both are downloadable from SSC using the -ssc- command in Stata.

Yet another pair, also doing string-numeric conversions in opposite directions, is -factext- and -factmerg-, also downloadable from SSC. However, these are specialist packages for producing confidence interval plots. The general user will be more likely to use -sencode- and -sdecode-.


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–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index