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"?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.