SAS Language Limits: 3 Examples
By : Admin_programmer -
In this post, you will see three examples of limits of the SAS language you may already have experienced.
The length of a variable is defined upfront, independent of the content of the variable. Well, you would say, it is not quite true ; if the first value of the character variable has 10 characters, then the length will be 10. You’re right on that. The problem is that the length of the first record is not always the maximum length of the variable.
What is the problem with that? It is not always possible to know upfront what the maximum length will be. There is no way that we can use the maximum length for character variables as it can be greater than 30 000 i.e. using more than 30 000 bytes consuming far too much space. It is possible to alter the length (alter statement in proc sql for example) but if the length is too short in first place the text will be truncated. The system is not able to increase the length of the variable based on the values it is reading.
Default Macro Parameter Value
It is not possible to call, using a macro function, the default value assigned to a macro parameter. Here is an example of what you cannot do:
%if &lib.=%str( ) %then &lib.=%default(lib);
This is the current setting by SAS 9.4 but I could imagine a function to be created in future versions.
Dates are stored in SAS using numerical values. 0 represents the 1st of January 1960. Adding 1 and you have the 2nd of January 1960, and so on. The problem is that it is not always possible to collect a complete date i.e. with day, month and year information. Sometimes, it is only possible to collect the month and the year and sometimes only the year is collected. Additional variables have to be created to store these partial information.