BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
David_Billa
Rhodochrosite | Level 12

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, ^, ^=, |, ||, ~, ~=. 
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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

 

View solution in original post

3 REPLIES 3
gamotte
Rhodochrosite | Level 12
Hello,

The first parenthesis is not closed.
I think you should remove the opening parentheis after the "or" :
or index(lowcase(....
Kurt_Bremser
Super User

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

 

Shmuel
Garnet | Level 18

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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 774 views
  • 3 likes
  • 4 in conversation