Here, the output of the proc contents shows the length of the variable "result" is 200. I remember the length of the resultant variable when using "repeat" function will be 200. But, when i open the dataset "one" to see the value of "length_var" which should have the length of the variable "result", is only 33. What may the reason behind this?
The attribute length of the variable "result" is determined at compile time and the value of the variable "length_var" which is the output of the length function is determined only at execution time. Is this the reason?
Won't the SAS consider the attributes of the variable "result" when scanning the the line 4 during compile time?
The LENGTH function resolves with each variable interrogation (at execution time -- and on each DATA step iteration).
So, even within a single DATA step pass, you could alter the SAS CHARACTER variable contents (shorten or lengthen) and the LENGTH will report a result, based on the current contents (without considering any blank-padding) -- it does not reflect the SAS system dataset declared (or implied) variable length -- which is actually the maximum length possible, when considering truncation.
Recommended Google advanced search argument, this topic/post: