BookmarkSubscribeRSS Feed
paulga
Calcite | Level 5

Hi

 

I came across a code that sequentially takes a string from a list of strings (&syspbuff) separated by a "," or " ".

but I don't quite figure out why the delimiters should be %str(%,(,%)))   ? 

 

%let data_input = %scan(&syspbuff,1,%str(%,(,%))));

 

 

4 REPLIES 4
Kurt_Bremser
Super User

If &syspbuff contains commas, this will fail anyway, as the first comma will be interpreted as a parameter separator for the %scan function.

 

What do you (or the previous programmer) try to achieve with this?

paulga
Calcite | Level 5

Thanks for reply. 

The macro uses parmbuff option. &syspbuff is something like: (input_data, output_data, event_indicator, input_var)

among the parameters, the input_var itself is a list of variables separated by ",". 

That line of code sequentially takes these parameters one by one. so the %scan function should use delimiters including , and left and right parentheses. I cannot figure out why the delimiter portion is written that way. 

ballardw
Super User

You may want to show 1) and example of how the macro is called actually called and if any of the parameters are macro variables what each of those macro variables resolve to at the time the macro is called. 3) It may be a good idea to show the entire macro code as well.

 

Imbedded special characters and for macro parameters comma is a special character can be touchy.

ballardw
Super User

Are you passing values to the macro that include ( or ) as part of the value?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 582 views
  • 0 likes
  • 3 in conversation