------------------------------------------------------------------------------- help for floattolong -------------------------------------------------------------------------------

Change float-type variables to long where possible.

floattolong [varlist]


This is simply a convenience, issuing recast long varlist2, where varlist2 is the set of variables in varlist that are of type float. This has some resemblance to, and is intended to complement compress, but the emphasis is on the appropriateness of the type rather than the reduction of storage space. (While compress does potentially change floats and doubles to integer types, it omits the possibility of changing a float to a long, as that does not reduce the storage space.)

floattolong would be typically used immediately following (or preceding) compress, and saves you the trouble of seeking out all the remaining float variables.

If no varlist is specified, _all is assumed.

floattolong ignores variables that are not float.


. floattolong

. floattolong wage income


floattolong can be used at any point, but is best used in conjunction with (immediately after or before) compress; without compress, it may recast some variables to long that might otherwise become int or byte.

In general data preparation, floattolong would usually be called without a varlist; there is little point in calling it with a specific set of variables, since you could just as well type recast long with the same varlist. The exception is where you use it within a program that generates a variable that is initially float, and you want to clean up that one variable without affecting others.

For a similar related program, see doubletofloat by the same author.


David Kantor, Institute for Policy Studies, Johns Hopkins University. Email dkantor@jhu.edu if you observe any problems.

Also see compress, recast, doubletofloat, datatypes