Stata Technical Bulletin
STB-57
dm70.1 Extensions to generate, extended: corrections
Nicholas J. Cox, University of Durham, UK, [email protected]
Abstract: Four egen functions published in Cox (1999) are corrected; three so that they work properly with long variable lists,
and one so that if restrictions work properly.
Keywords: eg en, data management, medians.
A previous insert (Cox 1999) described 24 extra functions for egen. This insert contains corrections for four of those.
First, eqany, neqany and tag now work properly when supplied with long variable lists. With each program, as previously
published, labeling the variable produced with a list of the variables supplied as arguments would fail with long lists.
Second, rmed now works correctly when issued with an if restriction. Previously, with an if restriction either all or none
of the observations were used, depending on whether or not the first observation was selected.
Acknowledgment
I am grateful to Benoit Dulong and Michael Blasnik for alerting me to these problems.
References
Cox, N. J. 1999. dm70: Extensions to generate, extended. Stata Technical Bulletin 50: 9-17. Reprinted in Stata Technical Bulletin Reprints, vol. 9,
pp. 34-45.
dm80.1 Update to changing numeric variables to string
Nicholas J. Cox, University of Durham, UK, [email protected]
Jeremy B. Wernow, Stata Corporation, [email protected]
Abstract: The command tostring introduced by Cox and Wernow (2000) has been revised to trap any misguided use of a
string format in conversion.
Keywords: string variables, numeric variables, data types, data management.
tostring (Cox and Wernow 2000) is a command for changing numeric variables to string. Optionally, users may select a
format to use in conversion, which is used as an argument to Stata’s string( ) function (see [U] 16.3.5 String functions). Such
a format should be numeric. For example, the option format(7,7.2f) specifies that numbers should be rounded to 2 decimal
places before conversion to string. However, a user inadvertently specifying a string format would find that the resulting variable
would always be an empty string. This is at best a misfeature; hence calls to format ( ) with a string format are now trapped
with an error message. The help file has also been revised to make this issue clearer.
Acknowledgment
We are grateful to Kit Baum for alerting us to this problem.
References
Cox, N. J. and J. B. Wernow. 2000. dm80: Changing numeric variables to string. Stata Technical Bulletin 56: 8-12.
dm81 Utility for time series data
Christopher F. Baum, Boston College, [email protected]
Vince Wiggins, Stata Corporation, [email protected]
Abstract: A program entitled tsmktim is described which makes the creation of time variables more convenient.
Keywords: time series, calendar, time variables.
Syntax
tsmktim newtimevar , StartWateJiteral) [sequence (varname)^
The tsmktim command provides a convenient way to generate the appropriate tsset command if you do not already have a time variable in the data.