What you are asking for is good old defensive programming. If one does
not care to have some value in each value for variable 'a' but would
like to know when a word does not meet the specifications, then you
could do the following.
data sub ;
set one ;
length a $12. ;
if length(word) >= 12 then do ;
a = substr(word,3,12) ;
word = ' is either blank or not long enough for the substr' ;
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Tuesday, September 28, 2004 1:52 PM
Subject: errors by function SUBSTR
When I use the function substr(var,num1,num2), there would be some
errors in the sas log if var=' ' (missing) or num2 is out of the
length of var.
In most of the cases it doesn't affect the results but I hate to see
errors in the log. Is there an alternative way to do this?