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=""), sep="/") return(x) } ) birthdays = as.Date(birthdays, format = "%d/%m/%Y") return(birthdays) }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.