I'm not certain why I get the out of range warning after executing the code below. Am I missing something?
data _null_; if symexist("_CD") then _CD = symget("_CD"); else _CD = ''; if symexist("ENTITY") then ENTITY = symget("ENTITY"); else ENTITY = ''; le=compress(COALESCEC(_CD,ENTITY)); call symput('le',le); *drop _:; run; Log: NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds WARNING: Argument 3 to macro function %SUBSTR is out of range.
Read the documentation:
Syntax
%SUBSTR(argument, position<, length>)%QSUBSTR(argument, position<, length>)Required Arguments
argument
position
is an integer or an expression (text, logical, or arithmetic) that yields an integer, which specifies the position of the first character in the substring. If position is greater than the number of characters in the string, %SUBSTR and %QSUBSTR issue a warning message and return a null value. An automatic call to %EVAL causes n to be treated as a numeric value.
length
is an optional integer or an expression (text, logical, or arithmetic) that yields an integer that specifies the number of characters in the substring. If length is greater than the number of characters following position in argument, %SUBSTR and %QSUBSTR issue a warning message and return a substring containing the characters from position to the end of the string. By default, %SUBSTR and %QSUBSTR produce a string containing the characters from position to the end of the character string.
All the best
Bart
Please COPY/PASTE (!!) the WHOLE log. Your code as posted does not contain ANY call of the %substr() macro function.
@David_Billa wrote:
I'm not certain why I get the out of range warning after executing the code below. Am I missing something?
data _null_; if symexist("_CD") then _CD = symget("_CD"); else _CD = ''; if symexist("ENTITY") then ENTITY = symget("ENTITY"); else ENTITY = ''; le=compress(COALESCEC(_CD,ENTITY)); call symput('le',le); *drop _:; run; Log: NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds WARNING: Argument 3 to macro function %SUBSTR is out of range.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.