Personal identity number (Sweden)

The personal identity number () is the Swedish national identification number. It is a ten or twelve digit number that is widely used in Sweden to identify individuals.
History.
When it was introduced in 1947 it was probably the first of its kind covering the total resident population of a country (The Social Security number in the United States is older, but it did not cover the whole population). Numbers are issued by the Swedish Tax Agency (Swedish: "Skatteverket") as part of the population register (Swedish: "Folkbokföring"). Until 1967, it had nine digits, and after that 10 digits. This was expanded to 12 digits in 1997 in cases of automated data treatment.
Use.
The number is used by authorities, by health care, schools and universities (both public-run and private). Also used by banks (needing it by law for tax purposes and mandatory customer identification) and insurance companies (needing it for car liability insurance and for medical travel insurance coordination). Other companies often ask for it in return for a post-paid service, such as a telephone subscription, to be able to check e.g. the person's credit record or address or if needed to perform debt collection.
The link between a person and the identity number is established through the civil registry and through identity documents and secondarily through the widespread use of the number in various contacts with authorities, businesses etc. They are necessary for personal service at banks, authorities, health care and other services which use the personal identity number. Most people are familiar with their full number and those of their children without hesitation. Personal identity numbers of individuals are openly available from the Swedish tax authorities to anyone who asks (over phone, letter, over the desk, but not over the internet), according to the Swedish principle of freedom of information. Redistribution of these numbers using computers is, however, governed by the law of personal details, an implementation of the Data Protection Directive.
Format.
The personal identity number consists of 10 or 12 digits and a hyphen. The first 6 or 8 digits correspond to the person's birthday, in YYMMDD or YYYYMMDD respectively. For automated data treatment the format for the date of birth is typically eight digits. In case the specific day is out of numbers, another day (close to the correct one) is used. They are followed by a hyphen, and four final digits. The year a person turns 100 the hyphen is replaced with a plus sign. A common misunderstanding is that the hyphen is replaced with a plus sign when the person turns 100 years old, but according to the definition, it happens the first of January that year. Among the four last digits, the three first are a serial number. For the last digit among these three, an odd number is assigned to males and an even number to females. 
Up to 1990, the assignment of serial number was correlated with the county where the bearer of the number was born or (if born before 1947) where he/she had been living, according to tax records, on January 1, 1947, with a special code (usually 9 as 7th digit) for immigrants. Since people rarely change identity number people assigned identity number before 1990 can still have their birth county or immigration identified.
The last digit is a checksum which was introduced in 1967 when the system was computerized. Originally, when the personal identity number was introduced, it had nine digits and the seventh and eighth denoted the county (Swedish: "län") in which the subject was born or had been living in 1947 - see above. The seventh digit was 9 for foreign born. This system was replaced with the current system in 1990. Everyone however keeps their number and it is not hard to find out someone's number if you know the birth date, the birth county and the checksum algorithm. Even easier is to call the tax authority and ask, since the personal identity number is public information.
With citizens and other persons born in Sweden, the identity number is issued soon after the birth of a child has been reported by the parents and medical professionals. In exceptional cases, the number may be changed later in life, typically because the date of birth or the registration of gender of the child were in error. If a person changes their legal gender, they will be issued a new identity number as well to reflect their new legal gender. Changes in the records of who were someone's biological parents do not affect the number, which has nothing to do with family circumstances.
A review on the Swedish Personal Identity Number was published in 2009 by medical researchers and representatives of the Tax authority, Statistics Sweden and the National Board of Health and Welfare.
There is a problem that the numbers are going to run out for certain dates, mainly the 1st of some months, which have been used in birth certificates in some countries where births often have not been properly registered. Often numbers that have been used by now deceased people are reused for the reason of lack of numbers, something that can cause problems.
The formal definition of a Swedish personal identity number is in Folkbokföringslagen.
Similar identity numbers.
People who have no Swedish personal identity number can receive a co-ordination number () instead. It is issued by the Tax Agency at the request of a public agency. It is used for contact between a person and an agency which would otherwise require the use of a personal identity number, for example for people have their main residence less than a year in the country or don't reside at all but needs authority contacts, e.g owning a summer house, or for Swedish citizens who have never been residents of Sweden. It is structured along the same lines, but with the day in the date of birth advanced by 60 (giving a number between 61 and 91). The reason for this routine is that there is a risk of running out of personal identity numbers. For EU/EEA citizens, is easier to get a co-ordination number than a personal identity number because the latter require evidence of work or education which would last at least a year, so many students or workers get a co-ordination number first and later a personal identity number. A Swedish identity card require personal identity number, while a bank account is troublesome to get with only a co-ordination number.
People who have no known Swedish personal identity number or co-ordination number but need health care, e.g. foreign tourists, unconscious people, newborn children needing special care (healthy newborn children are registered in their mother's medical record) and some more (e.g. for special privacy protection such as HIV tests), will get a reserve number () which is temporary and used only for the health care. They have the birth date (if known) and four more digits that can't be a real identity number.
Also, all organisations, including companies, have organisation numbers (). They look like personal identity numbers but have a "month" number of 20 or higher. They are used for tax purposes etc. and have to be printed on receipts.
The taxable assets of deceased people are, if not fully sold or inherited within 1-2 years, reassigned to organisation numbers, in order to free up Personal identity numbers for future children.
Checksum.
To calculate the checksum, multiply the individual digits in the 10-digit identity number and "212121-212". The resulting products (a two digit product, such as "16", would be converted to "1 + 6") are added together. The checksum is the last digit of "10" minus the last digit in this sum (note that if the last digit of the sum is zero, the checksum is "0"). For further details, see Luhn algorithm. For 12-digit numbers, the two first digits are omitted from the calculation.