National idenftification number: Finland

The Finnish Social Security number (FSSn) is a common variable in a Finnish population based study. Within FSSn are individuals birthday, and gender. We can also check if the FSSn correct because it has a check digit. If the data doesn't have birthday and gender variables or you want to check are they correct you can use the FSSn to do so.

FSSn has the form xxxxxxyzzzq. Where x:s denote persons birthday in the form of ddmmyy, and y is the century character. y can currently be + for 1800, - for 1900 and A for 2000. Persons gender can be seen in the zzz which can be thought of as individualizing numbers. zzz is an odd number for males and even for females. q is the check digit.

Function for the birthday would be.
#Given FSSn a vector of FSSn's
finID.bd = function(FSSn){
 FSSn = matrix(FSSn, nrow = length(FSSn)) 
 birthdays = apply(FSSn, 1, function(x){ 
  century = c("+", "-", "A") %in% substr(x, 7, 7)
  century = c("18", "19", "20")[century]
  x = paste(substr(x, 1, 2), substr(x, 3, 4), 
            paste(century, substr(x,5,6), sep=""), 
  birthdays = as.Date(birthdays, format = "%d/%m/%Y")

and for the gender
#Given FSSn a vector of FSSn's

finID.gender = function(FSSn, labels=c("female", "male")){
 FSSn = matrix(FSSn, nrow=length(FSSn))
 gender = apply(FSSn, 1, function(x){
                      x = as.double(substr(x, 10, 10)) %% 2 })
 return(factor(gender, levels=c(0,1), labels=labels))
Function for checking correctness of the FSSn and generating random FSSn's will be given later.

No comments:

Post a Comment