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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1302 views
  • 0 likes
  • 3 in conversation