DATA Step, Macro, Functions and more

How to pass macro parameters that contains commas, quotes...etc

Reply
N/A
Posts: 0

How to pass macro parameters that contains commas, quotes...etc

Hi all,

I'm hoping that you can help me to try and get this right.

I am trying to pass a piece of text into a macro as a macro parameter, but I keep getting

ERROR: Literal contains unmatched quote.
ERROR: The macro SQL_INSERT will stop executing.

The call macro call is :

%sql_insert(proj_name=&mvar_projectname,
idd=&mvar_id,
dt=&mvar_changed,
rq="&mvar_requirements",
category=&mvar_applicationcategory_k);

The macro variable is a variable length text paragraph that may contain commas, single/ double quotes, & symbols and unmatched quotes and parenthesis.

So, I have tried numerous quoting methods to no avail, like enclosing &mvar_requirements in %str()...etc. Is there a method to cover all symbols?

Hope someone can help.

Thanks in advance.
Super Contributor
Posts: 474

Re: How to pass macro parameters that contains commas, quotes...etc

Posted in reply to deleted_user
Hi.

Well, that depends on what your trying to quote.

see: http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001072333.htm

for macro quotting functions.

Greetings from Portugal.

Daniel Santos at www.cgd.pt
SAS Employee
Posts: 9

Re: How to pass macro parameters that contains commas, quotes...etc

Posted in reply to deleted_user
Try using %SUPERQ around the macro variable that is causing the problem, for example:

%sql_insert(proj_name=%superq(mvar_projectname),

It catches everything. Notice there is no & in front of the macro variable when using %SUPERQ.
Ask a Question
Discussion stats
  • 2 replies
  • 5663 views
  • 0 likes
  • 3 in conversation