So you have seen what results from the code, but why?
When creating a new variable, SAS has to decide what length to use. Why doesn't it use a length of 1, which is the third parameter to SUBSTR? The answer is that the third parameter does not have to be hard-coded. It could be an expression based on numeric variables on the data set (and could therefore vary from one observation to the next). So SAS doesn't even examine the third parameter to decide what length to use. To be safe, SAS decides to assign the length of the first parameter. After all, it might need that length if SUBSTR happens to select the entire string.
... View more