Appericiate if someone of you help me understand the problem with the code below.
Code:
else if (index(lowcase(filename),'_copied.csv') or (index(lowcase(filename),'_copied.xlsx') ) and "&function_compont" EQ 'NL' and (scan(lowcase(filename),5,'_') in ('5601','6010','6020')) then do;
Log:
else if (index(lowcase(filename),'_copied.csv') or (index(lowcase(filename),'_copied.xlsx') ) and "&function_compont" 108 ! EQ 'NL' and (scan(lowcase(filename),5,'_') in ('5601','6010','6020')) then do; SYMBOLGEN: Macro variable FUNCTION_COMPONT resolves to NL 108 else if (index(lowcase(filename),'_copied.csv') or (index(lowcase(filename),'_copied.xlsx') ) and "&function_compont" 108 ! EQ 'NL' and (scan(lowcase(filename),5,'_') in ('5601','6010','6020')) then do; ____ 22 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, ), *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.
Writing unstructured spaghetti crap like that will always get you in trouble.
I use the expletive on purpose here. If I saw such a line in production code, they would hear my yelling (while dressing down the **** who spit it out) in the CEO's office. Who works about half a mile (as the crow flies) from me.
Just slightly exaggerating.
See if this works for you:
else if
(
index(lowcase(filename),'_copied.csv') or
index(lowcase(filename),'_copied.xlsx')
) and
"&function_compont" EQ 'NL' and
scan(lowcase(filename),5,'_') in ('5601','6010','6020')
then do;
Of course, I had to make guesses about your logic.
Also make use of the features of the Enhanced Editor, which highlights closing brackets when the cursor is positioned before the opening bracket, and opening brackets if the cursor is positioned after a closing bracket.
But this all will only work for you if you make your code readable.
Maxim 12
Maxim 12
Maxim 12
Writing unstructured spaghetti crap like that will always get you in trouble.
I use the expletive on purpose here. If I saw such a line in production code, they would hear my yelling (while dressing down the **** who spit it out) in the CEO's office. Who works about half a mile (as the crow flies) from me.
Just slightly exaggerating.
See if this works for you:
else if
(
index(lowcase(filename),'_copied.csv') or
index(lowcase(filename),'_copied.xlsx')
) and
"&function_compont" EQ 'NL' and
scan(lowcase(filename),5,'_') in ('5601','6010','6020')
then do;
Of course, I had to make guesses about your logic.
Also make use of the features of the Enhanced Editor, which highlights closing brackets when the cursor is positioned before the opening bracket, and opening brackets if the cursor is positioned after a closing bracket.
But this all will only work for you if you make your code readable.
Maxim 12
Maxim 12
Maxim 12
Here is your code copied from the log:
else if (index(lowcase(filename),'_copied.csv') or (index(lowcase(filename),'_copied.xlsx') ) and "&function_compont" EQ 'NL' and (scan(lowcase(filename),5,'_') in ('5601','6010','6020')) then do;
you miss an open parenthesis on first line - where it is closed on second line. Check is this what you meant. You don't need last pair of parenthesis.
else if ((index(lowcase(filename),'_copied.csv') or
(index(lowcase(filename),'_copied.xlsx') )
and "&function_compont" EQ 'NL' and
scan(lowcase(filename),5,'_') in ('5601','6010','6020')
then do;
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.