Strong vs Loose Typing

From sasCommunity

Jump to: navigation, search


[edit] Overview

SAS uses loose (or weak) typing for variables. This means that SAS only has 2 variable types: numeric and character. Many modern languages employ strong typing with lots of variable types (datetimes, ints, enums, doubles, floats, etc.). This difference in variable typing can cause a lot of difficulties when translating between SAS and other languages.

There has been considerable debate over the value of one or the other. They each have strengths and weaknesses. Another factor in that debate vis-a-vis SAS is how long SAS has been around and the nature of the systems at the time it was created.

[edit] Example

Since SAS variables do not contain metadata regarding what their ultimate type may be, it is necessary to provide a mechanism for translating between systems.

Here is an example of a SAS dataset:

 Name                    Date                     Location

 Alan                    17133                    17133
 Marge                   17431                    17133

There is no way to say that date is a date rather than an integer. A format/informat can possibly shed a clue but not in all cases. Hence, without a foolproof way to say that ‘Date’ is a date or an integer, a person cannot automatically make an assumption for a strong type.


[edit] Possible Approaches

A possible approach for handling type conversions is to use a metadata lookup table. This approach would require that the user maintain a list of SAS datasets, which variables are contained within those datasets, and what type they represent in the other system.

Please see this utility for a possible approach:

SAS Metadata Creator

--Savian 11:06, 6 May 2007 (EDT)

Personal tools