When importing from an Excel file (and perhaps in other situations), numeric values import as doubles even when they don't really have or need that precision. In such situations, I'm compulsive enough to not want to store them as doubles. On discovering that -compress- would not compress them to floats, I figured I would just replace each bogus double variable with its float() representation, and then compress, which didn't do anything, as it left the floated values as doubles. Here's an illustration:
Code:
clear set obs 1 gen double x = 1.23 compress recast x, force desc
The time this would matter would be when one genuinely needs to compress a large file, with a sizeable number of bogus double variables. -recast float x1-x999, force- will work in that case, but I'd wager that most of us don't tend to recall that -recast- is out there.
0 Response to -float- and -compress- don't quite handle "bogus" doubles
Post a Comment