Thanks to Kit Baum, new versions of the -sencode- and -sdecode- packages are now available for download from SSC. In Stata, use the -ssc- command to do this, or the -adoupdate- command, if you already have earlier versions.
The -sencode- and -sdecode- packages are "super" versions of -encode- and -decode-, respectively, and are described as below on my website. The new versions are updated to Stata Version 10, and now have .sthlp on-line help files. However, users of earlier versions of Stata can still download the Stata 7 or 9 versions of -sencode- and -sdecode- by typing, in Stata,
net from "http://www.imperial.ac.uk/nhli/r.newson/stata7/"
for the Stata 7 packages, or
net from "http://www.imperial.ac.uk/nhli/r.newson/stata7/"
for the Stata 9 packages.
The -sencode- package has also been improved by the addition of a -fast- option for programmers, the addition of a -replace- suboption to the -label()- option allowing the user to overwrite existing value labels of the same name as the value label generated by -sencode-, and the use of Mata to do some work previously done using file processing.
Best wishes
Roger
Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected]
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/
Opinions expressed are those of the author, not of the institution.
------------------------------------------------------------------------------------------
package sencode from http://www.imperial.ac.uk/nhli/r.newson/stata10
------------------------------------------------------------------------------------------
TITLE
sencode: Encode a string variable non-alphanumerically into a numeric variable
DESCRIPTION/AUTHOR(S)
sencode is an extended version of encode. It takes, as input, a string
variable, and generates, as output, a numeric variable, with value labels
corresponding to values of the string variable. The output numeric variable
may replace the input string variable or be generated as a new variable.
sencode orders the numeric values corresponding to string values in the
sequential order of appearance in the input string variable in the data set,
or in another order specified by the user, instead of ordering them in
alphanumeric order of the string value, as encode does. The mapping from
numeric code values to string labels may be one-to-one (coded in order of
first appearance of the string value) or many-to-one (coded in each
observation by the position of that observation in the data set, or in the
user-specified ordering).
Author: Roger Newson
Distribution-Date: 14april2009
Stata-Version: 10
INSTALLATION FILES (click here to install)
sencode.ado
sencode.sthlp
------------------------------------------------------------------------------------------
(click here to return to the previous screen)
--------------------------------------------------------------------------------------
package sdecode from http://www.imperial.ac.uk/nhli/r.newson/stata10
--------------------------------------------------------------------------------------
TITLE
sdecode: Decode a numeric variable to string, formatting unlabelled values
DESCRIPTION/AUTHOR(S)
sdecode is an extended version of decode. It takes, as input, a numeric
variable, and generates, as output, a string variable, with values
corresponding to value labels of the numeric variable for labelled values,
and (optionally) formatted values of the numeric variable for unlabelled
values. The output string values therefore appear as the numeric input
values appear in output from the tabulate command. The output string
variable may replace the input numeric variable or be generated as a new
variable.
Author: Roger Newson
Distribution-Date: 14april2009
Stata-Version: 10
INSTALLATION FILES (click here to install)
sdecode.ado
sdecode.sthlp
--------------------------------------------------------------------------------------
(click here to return to the previous screen)
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/