Tuesday 6 September 2011

NOTE: Changing the Default Length for Numeric Values

Choosing appropriate lengths for the variables in your SAS data sets can have a significant effect on the size of your SAS datasets and hence a) the disk space they consume, and b) the speed with which they are written to and read from disk.

The default length for numeric values is 8 bytes; this is the maximum length too. For non-integer values you shorten the length at your peril, but if you're using integer values then you can consider shortening the length(s) and saving disk space.

The LENGTH statement's DEFAULT parameter allows you to specify a default length for newly-created numeric values. This can be useful if you are creating a number of date variables and/or binary flags.

SAS paper TS-654 provides plenty of information on numeric precisaion. Crucially, the table at the bottom of the second page shows the range of integer values you can safely store in variables of reduced length.