Which delimiter to use when scanning &SYSPBUFF?

Reply
New Contributor
Posts: 2

Which delimiter to use when scanning &SYSPBUFF?

[ Edited ]

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(%,(,%))));

 

 

Esteemed Advisor
Posts: 6,706

Re: code help

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?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 2

Re: code help

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. 

Grand Advisor
Posts: 10,251

Re: code help

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.

Grand Advisor
Posts: 10,251

Re: Which delimiter to use when scanning &SYSPBUFF?

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

Ask a Question
Discussion stats
  • 4 replies
  • 263 views
  • 0 likes
  • 3 in conversation