BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sathya66
Barite | Level 11

Hi All,

how to mask single and double quotes from my password.

proc pwen code is not working if my password has single and double quotes.

even if I use %str.

%let d=%nrstr(,3xc'wqm_W");

 

proc pwencode in= ",3xc'wqm_W"";
run;

 Thanks,

SS

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Have you tried the usual way?  Within double quotes refer to a double quote with an extra double quote character:

 

proc pwencode in= ",3xc'wqm_W""";
run;

View solution in original post

8 REPLIES 8
Astounding
PROC Star

Have you tried the usual way?  Within double quotes refer to a double quote with an extra double quote character:

 

proc pwencode in= ",3xc'wqm_W""";
run;
sathya66
Barite | Level 11

I tried this but  I doubt, will SAS take extra double Quote as a letter or will it mask  ",3xc'wqm_W"""

Astounding
PROC Star

SAS uses this syntax everywhere else within the software.  There's now reason why PWENCODE should be different.

 

Within double quotes, consecutive double quotes get treated as a single double quote character.  With three double quotes in a row, the first two combined get treated as a double quote character, and the third one ends the quoted string.

AnandVyas
Ammonite | Level 13
SAS treats the two consecutive quotation marks as one quotation mark.
AnandVyas
Ammonite | Level 13
Just In-case any non programmer background admin stumbles upon this situation you can use a workaround to get auto generated encoded password. Create an auth in SMC and add the required credentials as part of that auth. Create a library in SMC using the auth. Once created, right click the library and select display libname statement. This should show the libname with encoded pass.
Tom
Super User Tom
Super User

Please show the actual code since what you show is not using the macro variable you created. 

Did you use %STR() or %NRSTR()?  I would think you would want %STR() or %BQUOTE() since you have no need to remove the macro quoting.

 

But it is much easier to use normal quoting instead of macro quoting.  Just double the embedded quotes. So either of these should work.

",3xc'wqm_W"""
',3xc''wqm_W"'

Or just use the QUOTE() function to add the quotes.  

%let d=%bquote(,3xc'wqm_W");
proc pwencode in=%qsysfunc(quote(%superq(d)));
run;

 

sathya66
Barite | Level 11

getting below error
28 %let d=%bquote(,3xc'wqm_W");
29 proc pwencode in=%qsysfunc(quote(%superq(d)));
NOTE: Line generated by the macro function "QSYSFUNC".
29 ",3xc'wqm_W"""
_
22
76
ERROR 22-322: Expecting a quoted string.
ERROR 76-322: Syntax error, statement will be ignored.
30 run;

Tom
Super User Tom
Super User
Probably the macro quoting added by %Qsysfunc.
Use %sysfunc instead. But in that case I would pass the QUOTE() function a single quote as the second argument so that it generates a string quoted with single quotes. That way any & or % characters in the string will be ignored by the macro processor.
%sysfunc(quote(%superq(d),%str(%'))

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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