Reputation: 43
Do somebody know why the number stocked in "numero" isn't the same that the one I put in the let ?
I use SAS Enterprise Guide 7.1.
Here's my program :
%let ident = 4644968792486317489 ;
data _null_ ;
numero= put(&ident.,z19.);
call symputx('numero',numero);
run;
%put &numero. ;
And the log :
30 %let ident = 4644968792486317489 ;
31
32 data _null_ ;
33 numero= put(&ident.,z19.);
34 call symputx('numero',numero);
35 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
36
37 %put &numero. ;
4644968792486317056
Thanks by advance !
Upvotes: 4
Views: 206
Reputation: 27498
Use the SAS MD5
function to anonymize strings. Don't forget MACRO is really just text processing.
%let ident = 4644968792486317489 ;
%let numero = %sysfunc(MD5(&ident));
or in DATA Step
data ... ;
numero = MD5("&ident");
In certain situations you might associate a monotonic serial value to an identity value.
%let ident = 4644968792486317489 ;
%if not %symexist(i&ident) %then %do;
%let i&ident = %sysfunc(monotonic());
%put new serial;
%end;
%put i&ident=&&i&ident;
----- LOG -----
i4644968792486317489=1
Upvotes: 0
Reputation: 51566
SAS stores numbers as 8 byte floating point values. Therefore there is a limit to the maximum integer that can be stored exactly (or really exactly without gaps). They even publish a table with the maximum value.
And a function you can use to determine the maximum value.
3 %put %sysfunc(constant(exactint),comma23.);
9,007,199,254,740,992
Looks like your "number" is really an identifier. So store it as character to begin with and you will not have these problems.
data want;
length numero $19;
numero = "&ident";
numero = translate(right(numero),'0',' ');
run;
Upvotes: 5