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

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 829 views
  • 1 like
  • 3 in conversation