Calculate a SAS Observation Length

This post was kindly contributed by SAS from Out in Left Field - go there to comment and to read the full post.

Well, I couldn’t find this documented anywhere (someone correct me if I missed it) but the question for the day was how to calculate the SAS Observation Length. After some investigation, here is how it is done (pseudocode):

obsLength = Sum of all of your character lengths + Sum of all of your variable lengths;

if any numeric variables have a length of 8 then
round the obsLength to the nearest factor of 8.

Since the default for numeric variables is a length of 8, the rounding will almost always occur but it is not a guarantee.

I hope this helps others who may need to calculate this value for storage or performance reasons.

This post was kindly contributed by SAS from Out in Left Field - go there to comment and to read the full post.