Hi, I need to check Swedish personal identity numbers and need code to check wether the numer in a variable is correct or not. Please submit code if you have any.
What is the exact condition for the number to be valid?
In reference to your thread title, you might take a look at the mod() function (if this is somehow used to verify that the number is a valid one)
The modulo of 35 by 10 would be 5. Where in the number should the 5 be found? Or should 5 then be the sum of the digits of the last 2 positions?
A preliminary implementation of the check algorithm looks like this:
data _null_;
x = '196308101632';
sum = 0;
do i = 1 to 10;
sumi = input(substr(x,i,1),1.);
if mod(i,2) = 1
then do;
sumi = sumi * 2;
if sumi > 10 then sumi = sumi - 9;
end;
sum + sumi;
put i=;
put sumi=;
end;
put sum=;
check = mod(sum,10);
put check=;
run;
The question is now, with what should we compare the value "check"?
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.