DATA Step, Macro, Functions and more

In list with scan function

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 123
Accepted Solution

In list with scan function

I'm trying to see if a string that is returned by a scan function can be checked for in a list of strings as such:

 

if scan(CAG_code,3,"$") in("5234E","4321B","4456C")  --> this is throwing a syntax error

 

an example of what CAG_code looks like is: 2286$2983$4456C


Accepted Solutions
Solution
‎05-27-2016 12:19 PM
Super User
Posts: 10,483

Re: In list with scan function

No error with this:

data junk;
   CAG_code= '2286$2983$4456C';
   if scan(CAG_code,3,"$") in("5234E","4321B","4456C") then put 'Found';
run;

Log and error message please.

 

 

My $0.02 guess: error on previous line such as missing ;

View solution in original post


All Replies
Super User
Posts: 5,256

Re: In list with scan function

Show the log...
Data never sleeps
Solution
‎05-27-2016 12:19 PM
Super User
Posts: 10,483

Re: In list with scan function

No error with this:

data junk;
   CAG_code= '2286$2983$4456C';
   if scan(CAG_code,3,"$") in("5234E","4321B","4456C") then put 'Found';
run;

Log and error message please.

 

 

My $0.02 guess: error on previous line such as missing ;

Frequent Contributor
Posts: 123

Re: In list with scan function

Yes, you were right! I was simply missing a semicolon.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 245 views
  • 1 like
  • 3 in conversation