L H
L H

Reputation: 3

SAS: How to prevent "WARNING: Apparent invocation of macro not resolved" within a libname statement?

I have to use a password similar to the password below within a LIBNAME statement. The password includes a percentage sign (%) which results in the WARNING: Apparent invocation of macro PS not resolved:

LIBNAME EXAMPLE ORACLE
user=user1
password="'thisisapassword%PS|("
PATH=PATH1
SCHEMA=SCHEMA1
;

Because the password already includes a single quote, I have to use double quotes for the password, eventually resulting in a warning due to the percentage sign being used

I can't find how to escape this % or any other way to prevent this warning from occuring

Upvotes: 0

Views: 2128

Answers (2)

imnotarobot
imnotarobot

Reputation: 141

maybe you can test it. I can't test beacuse we don't use this characters in paswords but this can run witouth warning:

PROC PWENCODE IN="'thisisapassword%PS|(";
run;
%put &_PWENCODE;

LIBNAME EXAMPLE ORACLE
user=user1
password="&_PWENCODE"
PATH=PATH1
SCHEMA=SCHEMA1
;

Upvotes: 0

Richard
Richard

Reputation: 27508

Enclose the password in single quotes to prevent interaction with the macro system. Double up the single quote within the single quotes if the password literally contains a single quote.

Example:

PROC PWENCODE IN='''thisisapassword%PS|(';
/*                ^^                         ^^ showing where doubling up is needed */ 

From the documentation "Using Quotation Marks with Character Constants" (my bold):

If a character constant includes a single quotation mark, enclose it in double quotation marks. For example, to specify the character value Tom's as a constant, enter the following:

name="Tom's";

Another way to write the same string is to enclose the string in single quotation marks and to express the apostrophe as two consecutive quotation marks. SAS treats the two consecutive quotation marks as one quotation mark:

name='Tom''s';

The same principle holds true for double quotation marks and the character value Tom"s:

name="Tom""s";

Upvotes: 2

Related Questions