BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
whymath
Lapis Lazuli | Level 10

Hi, everyone.

 

Would you mind share me an usage example of %syscall scan() ? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@whymath wrote:

Hi, everyone.

 

Would you mind share me an usage example of %syscall scan() ? Thanks.


Oh, there is actually a call scan() routine. Never used it ever.

After some try and error below appears to work.

%let string=abc def ghi;
%let cnt=2;
%let pos=0;
%let len=0;
%syscall SCAN(string, cnt, pos, len );
%put &=cnt &=pos &=len;
CNT=2 POS=5 LEN=3

 

View solution in original post

4 REPLIES 4
Patrick
Opal | Level 21

@whymath wrote:

Hi, everyone.

 

Would you mind share me an usage example of %syscall scan() ? Thanks.


%syscall() is for using call routines on macro level, %sysfunc() for using functions on macro level.

scan() is a SAS function.

 

But...using %sysfunc() for the scan() function is not necessary as you've also got macro function %scan() for this.

%let string=abc def ghi;
%put test1: %sysfunc(scan(&string,2));
%put test2: %scan(&string,2);

 

28         %let string=abc def ghi;
29         %put test1: %sysfunc(scan(&string,2));
test1: def
30         %put test2: %scan(&string,2);
test2: def

 

andreas_lds
Jade | Level 19

@whymath wrote:

Hi, everyone.

 

Would you mind share me an usage example of %syscall scan() ? Thanks.


I rarely use call scan() it all, so i don't have an example at hand. Do you mind explaining the task you are working on (including some data), so that we can try to provide an example? Will functions/call-routines in the macro-world: don't use any kind of quotes.

whymath
Lapis Lazuli | Level 10
Severl days ago I was going to design a function findi() to find the ith position of a char or a string in a charater string. It seemed I went the wrong way and sadly I forgot the flash of thoughts. Thank you for you kind.
Patrick
Opal | Level 21

@whymath wrote:

Hi, everyone.

 

Would you mind share me an usage example of %syscall scan() ? Thanks.


Oh, there is actually a call scan() routine. Never used it ever.

After some try and error below appears to work.

%let string=abc def ghi;
%let cnt=2;
%let pos=0;
%let len=0;
%syscall SCAN(string, cnt, pos, len );
%put &=cnt &=pos &=len;
CNT=2 POS=5 LEN=3

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1076 views
  • 1 like
  • 3 in conversation