From: m1st on
Hello!

I'm trying to generate unique string identifier using md5() function
from macro %sysfunc like:
%let __hash = %nrbquote(%sysfunc(md5(%sysfunc(rand(UNIFORM)))));

It takes md5 hash from a textual representation of a uniformly
distributed random number. However, I've encountered some problems
when quoting the output of md5. %nrbquote-ing is still unable to catch
all the special characters appearing in md5 output.

The questions are:
1) How can I implement proper quoting in my case?
2) Or, if you have suggestions on implementing the same thing without
md5, please share your mind.
From: Richard A. DeVenezia on
On Jul 26, 5:27 am, m1st <lex.alt...(a)gmail.com> wrote:
> Hello!
>
> I'm trying to generate unique string identifier using md5() function
> from macro %sysfunc like:
> %let __hash = %nrbquote(%sysfunc(md5(%sysfunc(rand(UNIFORM)))));
>
> It takes md5 hash from a textual representation of a uniformly
> distributed random number. However, I've encountered some problems
> when quoting the output of md5. %nrbquote-ing is still unable to catch
> all the special characters appearing in md5 output.
>
> The questions are:
> 1) How can I implement proper quoting in my case?
> 2) Or, if you have suggestions on implementing the same thing without
> md5, please share your mind.

Try %QSYSFUNC

--
Richard A. DeVenezia
http://www.devenezia.com
From: m1st on
On Jul 26, 3:43 pm, "Richard A. DeVenezia" <rdevene...(a)gmail.com>
wrote:
> On Jul 26, 5:27 am, m1st <lex.alt...(a)gmail.com> wrote:
>
> > Hello!
>
> > I'm trying to generate unique string identifier using md5() function
> > from macro %sysfunc like:
> > %let __hash = %nrbquote(%sysfunc(md5(%sysfunc(rand(UNIFORM)))));
>
> > It takes md5 hash from a textual representation of a uniformly
> > distributed random number. However, I've encountered some problems
> > when quoting the output of md5. %nrbquote-ing is still unable to catch
> > all the special characters appearing in md5 output.
>
> > The questions are:
> > 1) How can I implement proper quoting in my case?
> > 2) Or, if you have suggestions on implementing the same thing without
> > md5, please share your mind.
>
> Try %QSYSFUNC
>
> --
> Richard A. DeVeneziahttp://www.devenezia.com

Actually, I tried it. No effect (more accurate, the same effect as the
mentioned %let).
It seems like SAS acquires macro quoting by mapping ASCII-codes of
special characters like % or & to some non-printable ASCII subset. The
fact is that MD5 returns a bit field, which is represented by 16
characters, not always printable, and sometimes they seem to collide
with SAS special quoting values.
Certainly, I can generate identifiers with data step, but as SAS does
not allow to include one datastep into another, this would be an ugly
solution.
From: Patrick on
"Certainly, I can generate identifiers with data step, but as SAS
does
not allow to include one datastep into another, this would be an ugly
solution. "

So what do you need this MD5 values for. What do you want to achieve?
What do you have and what do you need?
From: data _null_; on
On Jul 26, 7:56 am, m1st <lex.alt...(a)gmail.com> wrote:
> On Jul 26, 3:43 pm, "Richard A. DeVenezia" <rdevene...(a)gmail.com>
> wrote:
>
>
>
>
>
> > On Jul 26, 5:27 am, m1st <lex.alt...(a)gmail.com> wrote:
>
> > > Hello!
>
> > > I'm trying to generate unique string identifier using md5() function
> > > from macro %sysfunc like:
> > > %let __hash = %nrbquote(%sysfunc(md5(%sysfunc(rand(UNIFORM)))));
>
> > > It takes md5 hash from a textual representation of a uniformly
> > > distributed random number. However, I've encountered some problems
> > > when quoting the output of md5. %nrbquote-ing is still unable to catch
> > > all the special characters appearing in md5 output.
>
> > > The questions are:
> > > 1) How can I implement proper quoting in my case?
> > > 2) Or, if you have suggestions on implementing the same thing without
> > > md5, please share your mind.
>
> > Try %QSYSFUNC
>
> > --
> > Richard A. DeVeneziahttp://www.devenezia.com
>
> Actually, I tried it. No effect (more accurate, the same effect as the
> mentioned %let).
> It seems like SAS acquires macro quoting by mapping ASCII-codes of
> special characters like % or & to some non-printable ASCII subset. The
> fact is that MD5 returns a bit field, which is represented by 16
> characters, not always printable, and sometimes they seem to collide
> with SAS special quoting values.
> Certainly, I can generate identifiers with data step, but as SAS does
> not allow to include one datastep into another, this would be an ugly
> solution.- Hide quoted text -
>
> - Show quoted text -

If you format the string could you still use it?

13 %let __hash = %qsysfunc(md5(%sysfunc(rand(UNIFORM))),hex16);
14
15 %put &__hash;
95C9FCF9CB0E4579